BookmarkSubscribeRSS Feed
alepage
Barite | Level 11

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.

7 REPLIES 7
SASKiwi
PROC Star

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.

 

alepage
Barite | Level 11
Yes!

proc options option = xcmd;
30 run;

SAS (r) Proprietary Software Release 9.4 TS1M8

XCMD Enables the X command in SAS.
alepage
Barite | Level 11

Could you please provide an example of code using the x  command and sending the info in a dataset

Kurt_Bremser
Super User

@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.

alepage
Barite | Level 11
data files;
30 infile pipe "find /dwh_actuariat/sasdata/sas2023/be/auto -name \*.sas7bdat";

_______________________________________________________________
23
ERROR 23-2: Invalid option name "find /dwh_actuariat/sasdata/sas2023/be/auto -name \*.sas7bdat".

31 input;
32 file = _infile_;
33 run;
Reeza
Super User

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. 

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
SAS Enterprise Guide vs. SAS Studio

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 7 replies
  • 986 views
  • 4 likes
  • 4 in conversation