Macros for SAS Application Developers
https://github.com/sasjs/core
mf_getvarlist.test.sas
Go to the documentation of this file.
1 /**
2  @file
3  @brief Testing mf_getvarlist macro
4 
5  <h4> SAS Macros </h4>
6  @li mf_getvarlist.sas
7 
8 **/
9 
10 
11 %let test1=%mf_getvarlist(sashelp.class);
12 %let test2=%mf_getvarlist(sashelp.class,dlm=X);
13 %let test3=%mf_getvarlist(sashelp.class,dlm=%str(,),quote=double);
14 %let test4=%mf_getvarlist(sashelp.class,typefilter=N);
15 %let test5=%mf_getvarlist(sashelp.class,typefilter=C);
16 
17 data work.test_results;
18  length test_description $256 test_result $4 test_comments base result $256;
19  test_description="Basic test";
20  base=symget('test1');
21  result='Name Sex Age Height Weight';
22  if base=result then test_result='PASS';
23  else test_result='FAIL';
24  test_comments="Comparing "!!trim(base)!!' vs '!!trim(result);
25  output;
26 
27  test_description="DLM test";
28  base=symget('test2');
29  result='NameXSexXAgeXHeightXWeight';
30  if base=result then test_result='PASS';
31  else test_result='FAIL';
32  test_comments="Comparing "!!trim(base)!!' vs '!!trim(result);
33  output;
34 
35  test_description="DLM + quote test";
36  base=symget('test3');
37  result='"Name","Sex","Age","Height","Weight"';
38  if base=result then test_result='PASS';
39  else test_result='FAIL';
40  test_comments="Comparing "!!trim(base)!!' vs '!!trim(result);
41  output;
42 
43  test_description="Numeric Filter";
44  base=symget('test4');
45  result='Age Height Weight';
46  if base=result then test_result='PASS';
47  else test_result='FAIL';
48  test_comments="Comparing "!!trim(base)!!' vs '!!trim(result);
49  output;
50 
51  test_description="Char Filter";
52  base=symget('test5');
53  result='Name Sex';
54  if base=result then test_result='PASS';
55  else test_result='FAIL';
56  test_comments="Comparing "!!trim(base)!!' vs '!!trim(result);
57  output;
58 
59  drop base result;
60 run;