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

Hello,

I need help because, I don't have any idea , how to do that.

 

First, from a root directory, I have gathered in one dataset the complete path of each subfolder that are not empty and does not contains the name old.  I have put those various path's name in the dataset subdirectories under the variable foldername.

 

from there, I would like to use the following macro function and gather the information about the files hosted in each of those subfolders.

 

%macro FindFile(Path= , Command=);
/*This proc is to check if xcmd is enable. It must be enable
in order to use the unix command below*/
proc options option=xcmd;
run;

/*The %put is to see the value of FileName and Path into the logFile*/

%put &Command;
%put &Path;

/*Using the UNIX Commands find with (PIPE)*/

filename findfile PIPE "ls &Path. -l --time-style=long-iso | grep ^- | tr -s ' ' | cut -d ' ' -f 5,6,8";

data sasuser.fileslist;
infile findfile truncover;
input filelisting $200.;
run;
%mend FindFile;

 

So I am looking a way to pick one by one the name of the subfolder from the subdirectories dataset, and use it 

in

%FindFile(Path=Path1);

%FindFile(Path=Path2);

...

%FindFile(Path=Path11);

 

and gather all the information in one dataset.

 

How do we do that?

Thanks in advance for help

 

 

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

PROC APPEND is your friend.  So create one dataset with the DATA step and then use PROC APPEND to append it to the aggregate dataset you are trying to create. (PS Avoid using SASUSER as it will be readonly if you happen to be running more than one SAS session at the same time.)

data current_list;
  infile findfile truncover;
  input filelisting $200.;
run;
proc append base=full_list data=current_list force;
run;

View solution in original post

1 REPLY 1
Tom
Super User Tom
Super User

PROC APPEND is your friend.  So create one dataset with the DATA step and then use PROC APPEND to append it to the aggregate dataset you are trying to create. (PS Avoid using SASUSER as it will be readonly if you happen to be running more than one SAS session at the same time.)

data current_list;
  infile findfile truncover;
  input filelisting $200.;
run;
proc append base=full_list data=current_list force;
run;

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 692 views
  • 1 like
  • 2 in conversation