I have following SAS code that looks for "DailySales" files and import daily sales data into SAS data set. What i would like to do is the code to search for the "DailySales" files and if it doesn't find the "DailySales" files then use the "DailyImport" file.
the infile option FILEVAR= allows you to define the physical file name at runtime ( so, after you check that the file exists).
The FILEEXIST() function allows your data step to decide which to read
OK.I will give you a solution.The following code is right. I test it by myself.
[pre]
%let path=c:\;
filename fname pipe "dir &path.dailysales.txt &path.dailyimport.txt /B";
data want;
infile fname truncover;
input fname $20.;
fname="&path"||fname;
infile dummy filevar=fname end=last length=len;
do until( last);
input row $varying200. len;
output;
if last then stop;
end;
run;
[/pre]
There could be a number of reasons. From where are you running this code? Base SAS, EGuide?
If you are running it from Eguide, it may be that the object spawner is not allowed to execute external OS commands. You will need to add a NONOXCMD to the object spawner startup command.
Just looked again at your code. What exactly are you trying to do in the PIPE statement? You are missing the DIR in the filename statement.
Message was edited by: RMP
Message was edited by: RMP
Under Unix, you should use ' ls ' command to check the list of directory.
But from your log, it is to say you do not have right to use PIPE functionality.
If you can ,contact with SAS Administrator, to see whether to open it for you.
If you can not ,can refer to the SAS code which used fopen() function written by SASKiWi at previous post.