Production Ready Macros for SAS Application Developers
https://github.com/sasjs/core
mcf_string2file.test.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief Testing mcf_string2file macro
4
5 <h4> SAS Macros </h4>
6 @li mcf_string2file.sas
7 @li mp_assert.sas
8
9**/
10
11
12%mcf_string2file(wrap=YES, insert_cmplib=YES)
13
14data _null_;
15 rc=mcf_string2file(
16 "%sysfunc(pathname(work))/newfile.txt"
17 , "line1"
18 , "APPEND");
19 rc=mcf_string2file(
20 "%sysfunc(pathname(work))/newfile.txt"
21 , "line2"
22 , "APPEND");
23run;
24
25data _null_;
26 infile "%sysfunc(pathname(work))/newfile.txt";
27 input;
28 if _n_=2 then call symputx('val',_infile_);
29run;
30
31%mp_assert(
32 iftrue=(%str(&val)=%str(line2)),
33 desc=Check if APPEND works
34)
35
36data _null_;
37 rc=mcf_string2file(
38 "%sysfunc(pathname(work))/newfile.txt"
39 , "creating"
40 , "CREATE");
41run;
42
43data _null_;
44 infile "%sysfunc(pathname(work))/newfile.txt";
45 input;
46 if _n_=1 then call symputx('val2',_infile_);
47run;
48
49%mp_assert(
50 iftrue=(%str(&val2)=%str(creating)),
51 desc=Check if CREATE works
52)