Macros for SAS Application Developers
https://github.com/sasjs/core
mp_getcols.test.sas
Go to the documentation of this file.
1 /**
2  @file
3  @brief Testing mp_getcols macro
4 
5  <h4> SAS Macros </h4>
6  @li mp_getcols.sas
7  @li mp_assertcols.sas
8  @li mp_assertcolvals.sas
9  @li mp_assertdsobs.sas
10  @li mp_assertscope.sas
11 
12 **/
13 
14 
15 /* make some data */
16 proc sql;
17 create table work.src(
18  SOME_DATETIME float format=datetime19.,
19  SOME_CHAR char(16),
20  SOME_NUM num,
21  SOME_TIME num format=time8.,
22  SOME_DATE num format=date9.
23 );
24 
25 /* run macro, checking for scope leakage */
26 %mp_assertscope(SNAPSHOT)
27 %mp_getcols(work.src,outds=work.info)
28 %mp_assertscope(COMPARE)
29 
30 %mp_assertdsobs(work.info,
31  desc=Has 5 records,
32  test=EQUALS 5,
33  outds=work.test_results
34 )
35 
36 data work.check;
37  length val $10;
38  do val='NUMERIC','DATE','CHARACTER','DATETIME','TIME';
39  output;
40  end;
41 run;
42 %mp_assertcolvals(work.info.ddtype,
43  checkvals=work.check.val,
44  desc=All values have a match,
45  test=ALLVALS
46 )
47 
48 %mp_assertcols(work.info,
49  cols=name type length varnum format label ddtype fmtname,
50  test=ALL,
51  desc=check all columns exist
52 )