08-04-2014 02:30 PM
I have the following piece of SAS code that I run on Windows and works well. But now I am looking to run it from unix. I guess multiple things could go wrong here, so trying to resolve one at a time. What would be the equivalent Unix command for the filename command line? Should I use ls ? ... My equivalent folder in Unix is
/home/personal/bulk file all &date.
Note that there is a space in the folder name. Even though Windows seems to handle this, would be it also concern in Unix?
Appreciate your help deeply.
%let filepath = %bquote("C:\Personal\bulk file all &date");
filename cdr_Bulk pipe "dir &filepath /a:-d-h-s /b /s";
if scan(schedulefile,-1,'\') = "test.txt" then delete;
08-04-2014 03:49 PM
Well, I'm not sure of the meaning of all the options at the end of the DIR command. But it's probably sufficient on Unix to use:
... pipe "ls &filepath";
You may need to remove the double quotes within %BQUOTE.
Also note, you will need to change your delimiter in the SCAN function to a forward slash instead of a backward slash.
08-04-2014 10:25 PM
Probably the FIND command is the closest to want you were doing on DOS.
%let filepath = "C:\downloads" ;
if "&sysscp"="WIN" then cmd='dir /a:-d-h-s /b /s '||symget('filepath');
else cmd='find '||symget('filepath')||' -print';
infile cdr_buld pipe filevar=cmd truncover ;
input schedulefile $256.;
if scan(schedulefile,-1,'/\') = "test.txt" then delete;
08-05-2014 03:36 AM
Out of experience, I STRONGLY advise not to use blanks in directory/file names on a UNIX system. Always use the underline when you need to separate words. This will make your life so much easier when working with the command line tools, parameter substitution in shells etc.