Macros for SAS Application Developers
https://github.com/sasjs/core
Loading...
Searching...
No Matches
mp_validatecol.test.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief Testing mp_validatecol.sas macro
4
5 <h4> SAS Macros </h4>
6 @li mp_assertdsobs.sas
7 @li mp_validatecol.sas
8
9**/
10
11
12/**
13 * Test 1 - LIBDS
14 */
15data test1;
16 infile datalines4 dsd;
17 input;
18 libds=_infile_;
19 %mp_validatecol(libds,LIBDS,is_libds)
20 if is_libds=1;
21datalines4;
22some.libname
23!lib.blah
24%abort
25definite.ok
26not.ok!
27nineletrs._
28;;;;
29run;
30%mp_assertdsobs(work.test1,
31 desc=Testing LIBDS,
32 test=EQUALS 2,
33 outds=work.test_results
34)
35
36/**
37 * Test 2 - ISNUM
38 */
39data test2;
40 infile datalines4 dsd;
41 input;
42 infile=_infile_;
43 %mp_validatecol(infile,ISNUM,is_numeric)
44 if is_numeric=1;
45datalines4;
461
470001
481e6
49-44
50above are good
51the rest are bad
52%abort
531&somethingverybad.
54&
55+-1
56;;;;
57run;
58%mp_assertdsobs(work.test2,
59 desc=Test2 - ISNUM,
60 test=EQUALS 4,
61 outds=work.test_results
62)
63
64/**
65 * Test 3 - FORMAT
66 */
67data test3;
68 infile datalines4 dsd;
69 input;
70 infile=_infile_;
71 %mp_validatecol(infile,FORMAT,is_format)
72 if is_format=1;
73datalines4;
74$.
75$format.
76$format12.2
77somenum.
78somenum12.4
79above are good
80the rest are bad
81%abort
821&somethingverybad.
83&
84+-1
85.
86a.A
87$format12.1b
88$format12.1b1
89;;;;
90run;
91%mp_assertdsobs(work.test3,
92 desc=Test3 - ISFORMAT,
93 test=EQUALS 5,
94 outds=work.test_results
95)
96
97/**
98 * Test 4 - ISINT
99 */
100data test4;
101 infile datalines4 dsd;
102 input;
103 infile=_infile_;
104 %mp_validatecol(infile,ISINT,is_integer)
105 if is_integer=1;
106datalines4;
1071
1081234
109-134
110-1.0
1111.0
1120
113above are good
114the rest are bad
1150.1
1161.1
117-0.001
118%abort
1191&somethingverybad.
120&
121+-1
122.
123a.A
124$format12.1b
125$format12.1b1
126;;;;
127run;
128%mp_assertdsobs(work.test4,
129 desc=Test4 - ISFORMAT,
130 test=EQUALS 6,
131 outds=work.test_results
132)