Macros for SAS Application Developers
https://github.com/sasjs/core
Loading...
Searching...
No Matches
mv_createfile.test.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief Testing mv_createfile macro
4
5 <h4> SAS Macros </h4>
6 @li mf_uid.sas
7 @li mfv_existfile.sas
8 @li mp_assert.sas
9 @li mp_assertscope.sas
10 @li mv_createfile.sas
11
12
13**/
14
15options mprint;
16
17%let file=%mf_uid();
18
19%put TEST 1 - basic file upload ;
20filename somefile temp;
21data _null_;
22 file somefile;
23 put 'hello testings';
24run;
25%mp_assertscope(SNAPSHOT)
26%mv_createfile(path=&mcTestAppLoc/temp, name=&file..txt,inref=somefile,mdebug=1)
27%mp_assertscope(COMPARE
28 ,ignorelist=MCLIB0_JADP1LEN MCLIB0_JADP2LEN MCLIB0_JADPNUM
29 MCLIB0_JADVLEN MCLIB2_JADP1LEN
30 SASJSPROCESSMODE SASJS_STPSRV_HEADER_LOC
31 MCLIB2_JADP2LEN MCLIB2_JADPNUM MCLIB2_JADVLEN
32)
33
34%mp_assert(
35 iftrue=(%mfv_existfile(&mcTestAppLoc/temp/&file..txt)=1),
36 desc=Check if created file exists
37)
38
39%put TEST 2 - html file;
40filename f2 temp;
41data _null_;
42 file f2;
43 put '<html><body><p>Hello world</p></body></html>';
44run;
45%mv_createfile(path=&mcTestAppLoc/temp, name=test.html,inref=f2,mdebug=1)
46
47%mp_assert(
48 iftrue=(%mfv_existfile(&mcTestAppLoc/temp/test.html)=1),
49 desc=Check if created file exists
50)
51
52%put TEST 3 - dataset upload ;
53data temp;
54x=1;
55run;
56filename ds "%sysfunc(pathname(work))/temp.sas7bdat";
57
58%mv_createfile(path=&mcTestAppLoc/temp, name=&file..sas7bdat,inref=ds,mdebug=1)
59
60%mp_assert(
61 iftrue=(%mfv_existfile(&mcTestAppLoc/temp/&file..sas7bdat)=1),
62 desc=Check if created dataset exists
63)
64
65%put TEST 4 - create a .sas file;
66filename f4 temp;
67data _null_;
68 file f4;
69 put '%put hello FromSASStudioBailey; ';
70run;
71%mv_createfile(path=&mcTestAppLoc/temp, name=test4.sas,inref=f4,mdebug=1)
72
73%mp_assert(
74 iftrue=(%mfv_existfile(&mcTestAppLoc/temp/test4.sas)=1),
75 desc=Check if created sas program exists
76)
77
78
79
80%put TEST 5 - reading from files service and writing back;
81filename sendfrom filesrvc folderpath="&mcTestAppLoc/temp" filename='test4.sas';
82
83OPTIONS MERROR SYMBOLGEN MLOGIC MPRINT;
84
85%mv_createfile(path=&mcTestAppLoc/temp,name=test5.sas,inref=sendfrom,mdebug=1) ;
86