Macros for SAS Application Developers
https://github.com/sasjs/core
Loading...
Searching...
No Matches
mfv_existsashdat.test.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief Testing mfv_existsashdat macro function
4
5 <h4> SAS Macros </h4>
6 @li mf_uid.sas
7 @li mfv_existsashdat.sas
8 @li mp_assert.sas
9 @li mp_assertscope.sas
10
11 @sasjslint {"noBannedStrings": false}
12**/
13
14options mprint;
15
16/* ------------------------------------------------------------------------ */
17/* Setup: start a CAS session and stage a sashdat file in the Public caslib */
18/* ------------------------------------------------------------------------ */
19cas mysess;
20caslib _all_ assign;
21
22%let testcaslib = Public; /* change this if Public isn't available */
23proc cas;
24 table.caslibInfo result=r / ;
25 found = 0;
26 do row over r.CASLibInfo;
27 if upcase(row.Name) = upcase("&testcaslib") then found = 1;
28 end;
29 if found = 0 then do;
30 print "ERROR: caslib &testcaslib not available";
31 exit;
32 end;
33quit;
34%put NOTE: Using testcaslib=&testcaslib;
35
36%let tab1=T%mf_uid();
37
38proc casutil;
39 load data=sashelp.baseball outcaslib="&testcaslib" casout="&tab1" replace;
40 save casdata="&tab1" incaslib="&testcaslib"
41 casout="&tab1..sashdat" outcaslib="&testcaslib" replace;
42 droptable casdata="&tab1" incaslib="&testcaslib" quiet;
43quit;
44
45
46/* ------------------------------------------------------------------------ */
47%put TEST 1 - returns 1 when the sashdat file exists in the caslib;
48/* ------------------------------------------------------------------------ */
49%mp_assert(
50 iftrue=(%mfv_existsashdat(&testcaslib..&tab1)=1),
51 desc=Test 1 - Check returns 1 for a sashdat that exists
52)
53
54/* ------------------------------------------------------------------------ */
55%put TEST 2 - returns 0 when the file does not exist in the caslib;
56/* ------------------------------------------------------------------------ */
57%mp_assertscope(SNAPSHOT)
58%mp_assert(
59 iftrue=(%mfv_existsashdat(&testcaslib..DOESNOTEXIST_%mf_uid())=0),
60 desc=Check returns 0 for a sashdat that does not exist
61)
62%mp_assertscope(COMPARE,
63 desc=Check mfv_existsashdat does not leak macro variables into GLOBAL scope
64)
65
66/* ------------------------------------------------------------------------ */
67/* Teardown */
68/* ------------------------------------------------------------------------ */
69proc casutil;
70 deletesource casdata="&tab1..sashdat" incaslib="&testcaslib" quiet;
71quit;
72
73cas mysess terminate;
74
75%let syscc=0;