Macros for SAS Application Developers
https://github.com/sasjs/core
Loading...
Searching...
No Matches
mf_getvarnum.test.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief Testing mf_getvarnum macro
4
5 <h4> SAS Macros </h4>
6 @li mf_getvarnum.sas
7 @li mf_isblank.sas
8 @li mp_assert.sas
9 @li mp_assertscope.sas
10
11**/
12
13data work.varnum_test;
14 length first $8 second 8 third $1;
15 first='a';
16 second=2;
17 third='c';
18 output;
19run;
20
21%mp_assertscope(SNAPSHOT)
22%put scope check:%mf_getvarnum(work.varnum_test,first);
23%mp_assertscope(COMPARE,
24 desc=Checking that mf_getvarnum does not leak scope,
25 outds=work.test_results
26)
27
28%mp_assert(
29 iftrue=(%mf_getvarnum(work.varnum_test,first)=1),
30 desc=Checking the first variable returns 1,
31 outds=work.test_results
32)
33
34%mp_assert(
35 iftrue=(%mf_getvarnum(work.varnum_test,second)=2),
36 desc=Checking the second variable returns 2,
37 outds=work.test_results
38)
39
40%mp_assert(
41 iftrue=(%mf_getvarnum(work.varnum_test,third)=3),
42 desc=Checking the third variable returns 3,
43 outds=work.test_results
44)
45
46/* a variable that does not exist returns a blank */
47%let varnum_missing=%mf_getvarnum(work.varnum_test,nosuchvar);
48
49%mp_assert(
50 iftrue=(%mf_isblank(&varnum_missing)=1),
51 desc=Checking that a variable that does not exist returns blank,
52 outds=work.test_results
53)