BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Thylacine
Fluorite | Level 6

System is on unix i need a directory listing and tried:


filename dirlist pipe 'dir "pathTOdirectory" ';


data nazwy;
length fname $256;
infile dirlist truncover length= reclen;
input fname $varying256. reclen;
run;

 

but i keep getting all filenames in one row and not in seperate, what i'm i doing wrong?

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

On UNIX systems, use the native ls instead of the DOS dir mockup:

filename dirlist pipe 'ls path ';

data nazwy;
length fname $256;
infile dirlist truncover length= reclen;
input fname $varying256. reclen;
run;

View solution in original post

2 REPLIES 2
RW9
Diamond | Level 26 RW9
Diamond | Level 26

I always put a dlm= in the infile which can never happen in the returned information - you could probably look for CR/LF or other things:

filename dirlist pipe 'dir "pathTOdirectory" ';

data nazwy;
  length fname $256;
  infile dirlist truncover length=reclen dlm="¬";
  input fname $varying256. reclen;
run;

Thus, as the delimter is never hit, then it only goes to a new line on cr/lf.

Kurt_Bremser
Super User

On UNIX systems, use the native ls instead of the DOS dir mockup:

filename dirlist pipe 'ls path ';

data nazwy;
length fname $256;
infile dirlist truncover length= reclen;
input fname $varying256. reclen;
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 connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

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