Hello,
I would like to get the list of all SPDE files, sas7bdat, xlsx and .dat in a directory and its subdirectories on a Unix Server
For the spde file, I just want a name per file not each slice.
Do you have the ability to run OS commands from your server SAS sessions? You can check this by running this program to see your XCMD setting:
proc options option = xcmd;
run;
If XCMD is on then you can run OS commands like - ls - to get a list of all files in a directory.
Could you please provide an example of code using the x command and sending the info in a dataset
@alepage wrote:
Could you please provide an example of code using the x command and sending the info in a dataset
No X statement, but FILENAME PIPE:
data files;
infile pipe "find /path -name \*.sas7bdat";
input;
file = _infile_;
run;
But you should look at my presentation https://communities.sas.com/t5/SAS-User-Groups-Library/WUSS-Presentation-Talking-to-Your-Host/ta-p/8... which contains examples both for this and how to do it with SAS functions only.
Move the PIPE option after the command string. My bad.
I like using this macro %dirtree.
https://github.com/sasutils/macros/blob/master/dirtree.sas
%macro dirtree
/*---------------------------------------------------------------------------
Build dataset of files in directory tree(s)
----------------------------------------------------------------------------*/
(directory /* Pipe delimited directory list (default=.) */
,out=dirtree /* Output dataset name */
,maxdepth=120 /* Maximum tree depth */
);
Not sure anything will do the SPDE request, you'll likely need to wrangle the output yourself for that one.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.