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?
Try this instead of a single quote:
%str(%')
Also test without the macro variable to ensure it is working correctly in the first instance.
Try running the DIR command inside a piped SAS FILENAME. This post explains how:
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?
Try this instead of a single quote:
%str(%')
Also test without the macro variable to ensure it is working correctly in the first instance.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.