When I ran this macro code in EG 5.1,encountered by error as follows.SAS is installed in UNIX server and the /data/PPM is directory where SAS resides.
Ideally I want this code to run, when file is not availble on sever and if there are files it should produce a dataset as mentioned in macros.
16 %let appfile =<None>;
17
18 %macro do_work(infilename);
19 %if "&infilename" ne "<NONE>" %then %do;
20
21 proc import datafile="/data/PPM/&infilename." out=appfile_cass dbms=CSV replace;
22 guessingrows=30000;
23 run;
24
25 data want;
26 set appfile_cass;
27 run;
28
29 %end;
30 %mend;
31
32 %do_work(&appfile);
MLOGIC(DO_WORK): Beginning execution.
MLOGIC(DO_WORK): Parameter INFILENAME has value <None>
MLOGIC(DO_WORK): %IF condition "&infilename" ne "<NONE>" is TRUE
MPRINT(DO_WORK): proc import datafile="/data/PPM/<None>" out=appfile_cass dbms=CSV replace;
MPRINT(DO_WORK): ADLM;
MPRINT(DO_WORK): guessingrows=30000;
MPRINT(DO_WORK): run;
NOTE: Unable to open parameter catalog: SASUSER.PARMS.PARMS.SLIST in update mode. Temporary parameter values will be saved to
WORK.PARMS.PARMS.SLIST.
ERROR: Physical file does not exist, /data/PPM/<None>.
Can someone guide me to achieve this task?
Thanks for any help provided.
Check function FEXIST() .
Check the case of the parameters:
94 %let appfile =<NONE>;
95 %put &appfile;
<NONE>
96 options mprint mlogic;
97 %macro do_work(infilename);
98 %if "&infilename" ne "<NONE>" %then %do;
99
100 proc import datafile="/data/PPM/&infilename." out=appfile_cass dbms=CSV replace;
101 guessingrows=30000;
102 run;
103
104 data want;
105 set appfile_cass;
106 run;
107
108 %end;
109 %mend;
110 %do_work(&appfile);
MLOGIC(DO_WORK): Beginning execution.
MLOGIC(DO_WORK): Parameter INFILENAME has value <NONE>
MLOGIC(DO_WORK): %IF condition "&infilename" ne "<NONE>" is FALSE
MLOGIC(DO_WORK): Ending execution.
The error message is that there is no file named '<None>' in that directory.
You can use the %UPCASE() function to make your test for <NONE> case insensitive.
%if %upcase("&infilename") ne "<NONE>" %then %do;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.