04-16-2012 11:45 AM
A SAS job that runs on z/OS inputs three datasets via DD name - the SAS code has INFILE ddname statements. These datasets could be optional,and we'd like to change the SAS code so if a user doesn't specify one or more the job will run and just not try to process the data with DD name not found. I've seen some help in here on how to handle missing files with LIBNAME, but haven't found a way with an INFILE ddname. I think we could have the user put "DD DUMMY" if a DD won't be used, but we'd rather they not need to have the DD at all if nothing to input.
04-16-2012 12:39 PM
Last time I seriously used JCL was back with SAS 5.18. But with a current version of SAS you should be able to dynamically assign your input filename. Look at the MVS specific user manual for SAS. You also might need to have specially privileges based on how your MVS site is configured.
Look at the FILEVAR option on the INFILE statement. Or conditionally generate a FILENAME statement. Or even a FILENAME() function call.
04-16-2012 12:53 PM
specifies the fileref to be validated. Under z/OS, fileref can be a ddname that was assigned using the TSO ALLOCATE command or JCL DD statement. In a DATA step, fileref can be a character expression, a string enclosed in quotation marks, or a DATA step variable whose value contains the fileref. In a macro, fileref can be any expression. If fileref is a literal fileref name, it must be in quotation marks. If fileref is the name of a character variable whose value is a fileref name, it must not be quoted.
04-16-2012 01:23 PM
Thanks for the quick responses. I'm not much of a programmer, and have been reading about fileref and some other related things related to external files. If I can't get something proper to work, it looks like I may be able to sledgehammer it together by getting a list of DD names used in that job step via SASHELP.VEXTFL, and then if the DD name does not show up in there don't try to infile it. Once I get something to work all the way through I'll put it in here in case it might be of use.
04-16-2012 01:33 PM
Try this little program to see what the FILEREF function returns.
filename test1 temp;
filename test2 temp;
data _null_; file test2; run;
%put No file : %sysfunc(fileref(test1));
%put Empty file : %sysfunc(fileref(test2));
%put No fileref : %sysfunc(fileref(xxxx));
No file : -20006
Empty file : 0
No fileref : 20004
04-17-2012 07:49 AM
Thanks Tom, I think the %sysfunc(fileref(ddname)) will do it. On a test job with DDs for INPUT1, INPUT3 and INPUT4 the following gave 20004 for the INPUT2 DD name that wasn't in the JCL, so I know to bypass INPUT2.
%put INPUT1 : %sysfunc(fileref(INPUT1));
%put INPUT2 : %sysfunc(fileref(INPUT2));
%put INPUT3 : %sysfunc(fileref(INPUT3));
%put INPUT4 : %sysfunc(fileref(INPUT4));
INPUT1 : 0
INPUT2 : 20004
INPUT3 : 0
INPUT4 : 0