2 weeks ago
So this is similar but different from previous posts.
I am trying to create a list of directories (not files) in a DIS project.
In DIS I can get a list of all the folder contents using x ls -lp &file_path. >/tmp/folderlisting.csv;
In Bash script ls -d */ "filepath" works perfectly. However the */ is not working in SAS as it treats this as a comment end. Quoting this has not helped.
So, any help I could get in finding a solution or alternative to x ls -d */ "&filepath." >/tmp/folderlisting.csv; would be appreciated.
I am aware that could use multiple lines of code to search through the full output and create a new file but i am looking for an efficient streamlined solution.
NB I have also tried | grep ^d but again DIS doesn't like this.
a week ago
Thanks for the help. I tried lots of the variants suggested but the one that worked is ;
%sysexec (ls -l "&file_path" | grep ^d > /tmp/folderlisting.csv);
also had to do some double quoting of the variable file_path when setting it but that is all part of the differences in EG and DIS.
2 weeks ago
Use the filename pipe method:
filename oscmd pipe "ls -d */ '&filepath.' 2>&1"; data _null_; infile oscmd; input; put _infile_; run;
Then look at the log and see how you can use the output of the ls.
2 weeks ago - last edited 2 weeks ago
I wouldn't use the X command, but if you do then add quotes around the command you want to run so that the command does not get interpreted by SAS or the SAS macro processor.
filename list temp; x "ls -d ~/*/ > '%sysfunc(pathname(list))'" ; data _null_; infile list ; input; put _infile_; run;
Or easier still just use the PIPE engine and skip the temporary file.
data _null_; infile "ls -d ~/*/" pipe ; input ; put _infile_; run;
Need further help from the community? Please ask a new question.