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