SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

directory listing

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 12
Accepted Solution

directory listing

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?


Accepted Solutions
Solution
‎07-12-2017 09:59 AM
Super User
Posts: 7,809

Re: directory listing

Posted in reply to Thylacine

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;
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers

View solution in original post


All Replies
Super User
Super User
Posts: 7,970

Re: directory listing

Posted in reply to Thylacine

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.

Solution
‎07-12-2017 09:59 AM
Super User
Posts: 7,809

Re: directory listing

Posted in reply to Thylacine

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;
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
☑ This topic is solved.

Need further help from the community? Please ask a new question.

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