Macros for SAS Application Developers
https://github.com/sasjs/core
Loading...
Searching...
No Matches
mp_include.test.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief Testing mp_include macro
4
5 <h4> SAS Macros </h4>
6 @li mp_include.sas
7 @li mp_assert.sas
8
9 @details mp_include is called from inside a macro here, which is the case it
10 exists for. The included file records the four _SYSINCLUDE* values it can
11 see: they are created in the including scope for the duration of the include,
12 which is what the macro documents and what the file asserts.
13
14**/
15
16filename incref temp;
17
18data _null_;
19 file incref;
20 put 'data work.include_seen;';
21 put ' length device name dir fref $300;';
22 put ' device=symget("_SYSINCLUDEFILEDEVICE");';
23 put ' name=symget("_SYSINCLUDEFILENAME");';
24 put ' dir=symget("_SYSINCLUDEFILEDIR");';
25 put ' fref=symget("_SYSINCLUDEFILEFILEREF");';
26 put 'run;';
27run;
28
29%macro run_include_test();
30 %mp_include(incref)
31%mend run_include_test;
32
33%run_include_test()
34
35proc sql noprint;
36 select count(*) into: n_rows from work.include_seen;
37 select count(*) into: n_set from work.include_seen
38 where length(device)>0 and length(name)>0 and length(dir)>0
39 and fref='incref';
40quit;
41
42%mp_assert(
43 iftrue=(&n_rows=1),
44 desc=Checking that the included code is executed,
45 outds=work.test_results
46)
47
48%mp_assert(
49 iftrue=(&n_set=1),
50 desc=Checking that the four _SYSINCLUDE values are visible to the include,
51 outds=work.test_results
52)