BookmarkSubscribeRSS Feed
Matt3
Quartz | Level 8

Hi,

 

Could anyone please help me how to get all file names and and modification date from linux directory using windows is quit simple:

filename xl pipe 'dir /T:W "c:\test\*.xlsx"' 

but '*' signth for linux is not working:

filename xl pipe 'ls -r "/test/*.xlsx"'

 

Another problem is what variable names should I put in input statment to get just filename and last modification date.

 

data want;
 format moddate datetime20.;
 infile xl;
 input fname (?) $char50. moddate (?) 8.;
run;


 

 

2 REPLIES 2
ballardw
Super User

I don't know which wildcard to use in Linux LS command but you likely need to provide a complete path from your root (or the server) otherwise the execution is likely to be looking for a folder test in the location of the executing SAS session.

 

If you are unclear where to look in the output for desired bits perhaps you should direct the output of an X command using the LS to a text file instead of a Pipe. Then you would have something to look at you could parse.

 

Or you could use the SAS function DOPEN, Dread and such to read directly.

ChrisNZ
Tourmaline | Level 20

1- The star wildcard works fine when using ls.  Linux is case-sensitive though, while Windows in not.  Could this be the reason for you troubles?  (for example, it's    ls -R     not     ls -r   )

 

2- Try to see what your input line looks like and then parse it:

 

 


filename LS pipe 'ls -R "/test/*.xlsx"' ;

data WANT; 
  format MODDATE datetime20.; 
  infile LS pad; 
  input LINE 256.;
  FNAME=substr(X,..) etc; 
run;

   

sas-innovate-2024.png

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.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 2612 views
  • 0 likes
  • 3 in conversation