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 
14 data _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");
23 run;
24 
25 data _null_;
26  infile "%sysfunc(pathname(work))/newfile.txt";
27  input;
28  if _n_=2 then call symputx('val',_infile_);
29 run;
30 
31 %mp_assert(
32  iftrue=(%str(&val)=%str(line2)),
33  desc=Check if APPEND works
34 )
35 
36 data _null_;
37  rc=mcf_string2file(
38  "%sysfunc(pathname(work))/newfile.txt"
39  , "creating"
40  , "CREATE");
41 run;
42 
43 data _null_;
44  infile "%sysfunc(pathname(work))/newfile.txt";
45  input;
46  if _n_=1 then call symputx('val2',_infile_);
47 run;
48 
49 %mp_assert(
50  iftrue=(%str(&val2)=%str(creating)),
51  desc=Check if CREATE works
52 )