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

Someone is running data for me and saving the output in a sub folder of a Yearly directory.  For example, I have a folder called "2020" and the data that is being run for me gets output to subfolders called "Jan062020", "Jan132020", "Jan202020", etc. and within each of these folders are a couple of datasets that always has the same names. 

 

What I'd like to do is create a list of these sub folders that I can then loop over and pull in the datasets into an aggregated file.

 

I've spent some time Googling but can't find anything that fits my inquiry so I am hoping to find assistance here.

 

Thanks in advance for your time.

1 ACCEPTED SOLUTION

Accepted Solutions
andreas_lds
Jade | Level 19

Can you use x-commands in the sas-session?

If yes, you could use something like

filename dirs pipe 'dir "YOUR_PATH" /a:d /b';

data dirs;
  length dirName $ 200;
  infile dirs;
  input dirName;
run;

I don't have access to sas right now, so the code is untested.

View solution in original post

2 REPLIES 2
andreas_lds
Jade | Level 19

Can you use x-commands in the sas-session?

If yes, you could use something like

filename dirs pipe 'dir "YOUR_PATH" /a:d /b';

data dirs;
  length dirName $ 200;
  infile dirs;
  input dirName;
run;

I don't have access to sas right now, so the code is untested.

Reeza
Super User

Example 2: List All Files within a Directory Including Subdirectories

https://documentation.sas.com/?docsetId=mcrolref&docsetTarget=n0js70lrkxo6uvn1fl4a5aafnlgt.htm&docse...

 

Sample 24820: Creating a Directory Listing Using SAS for Windows

https://support.sas.com/kb/24/820.html

 


@GeorgeBonanza wrote:

Someone is running data for me and saving the output in a sub folder of a Yearly directory.  For example, I have a folder called "2020" and the data that is being run for me gets output to subfolders called "Jan062020", "Jan132020", "Jan202020", etc. and within each of these folders are a couple of datasets that always has the same names. 

 

What I'd like to do is create a list of these sub folders that I can then loop over and pull in the datasets into an aggregated file.

 

I've spent some time Googling but can't find anything that fits my inquiry so I am hoping to find assistance here.

 

Thanks in advance for your time.


 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 2 replies
  • 5076 views
  • 3 likes
  • 3 in conversation