Using infile Unix

Reply
New Contributor
Posts: 2

Using infile Unix

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.

Windows

%let filepath = %bquote("C:\Personal\bulk file all &date");

filename cdr_Bulk pipe "dir &filepath /a:-d-h-s /b /s";

data tempsetup;

infile cdr_Bulk;

input ;

schedulefile=_infile_;

if scan(schedulefile,-1,'\') = "test.txt" then delete;

run;

Respected Advisor
Posts: 4,969

Re: Using infile Unix

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.

Good luck.

Super User
Super User
Posts: 6,323

Re: Using infile Unix

Probably the FIND command is the closest to want you were doing on DOS.

%let filepath = "C:\downloads" ;

data tempsetup;

  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;

run;

Esteemed Advisor
Posts: 6,646

Re: Using infile Unix

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.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Ask a Question
Discussion stats
  • 3 replies
  • 174 views
  • 0 likes
  • 4 in conversation