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

Hi, I'm fairly new to SAS, and I'm trying to get a list of folders in a specific directory saved as a dataset.

 

I can get the folders using %sysexec like so:

 

%sysexec(dir -l "<folder location>" );

 

This opens the command prompt, which is not desirable. My question is, is there a way to save the command line output generated by this command? Maybe in a new dataset call folder_list or something?

1 ACCEPTED SOLUTION

Accepted Solutions
SASKiwi
PROC Star

Try this instead of a single quote:

%str(%')

Also test without the macro variable to ensure it is working correctly in the first instance.

View solution in original post

3 REPLIES 3
SASKiwi
PROC Star

Try running the DIR command inside a piped SAS FILENAME. This post explains how:

https://communities.sas.com/t5/New-SAS-User/How-to-define-the-output-of-sysexec-into-a-variable-so-t...

ABurn
Fluorite | Level 6

unfortunately it keeps returning 0 observations. I am using macro variables inside the pipe:

 

filename tmp pipe 'dir "F:\PROJECTS\Active\&FULL_TRIAL.\Data Management\4. Data Validation and Checking\Data Cleaning Procedures\" /b /s';

but I know sometimes macro variables don't work with single quotes. Is there a way around that?

SASKiwi
PROC Star

Try this instead of a single quote:

%str(%')

Also test without the macro variable to ensure it is working correctly in the first instance.

sas-innovate-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

Register now!

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
  • 3 replies
  • 1724 views
  • 1 like
  • 2 in conversation