☑ This topic is solved.
Need further help from the community? Please
sign in and ask a new question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 03-28-2023 10:55 AM
(1715 views)
I'm looking to get the output of unix command
%let myfile = x 'ls -tr /sas/data/mydata | tail -1';
to be added into the sas program as a variable &myfile to use in the program and I can get awa from hardcoded filenames.
Any ideas?
1 ACCEPTED SOLUTION
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You probably want to use a PIPE device, e.g.:
filename ls pipe 'ls -tr /sas/data/mydata | tail -1';
data want;
infile ls;
input <whatever you want from the input>; call symputx('myfile',<the variable you read>);
run;
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
This macro, not mine, will generate the directory listing of a folder into a data set and can recursively search the subfolders. Set the depth to control it not searching.
https://github.com/sasutils/macros/blob/master/dirtree.sas
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You probably want to use a PIPE device, e.g.:
filename ls pipe 'ls -tr /sas/data/mydata | tail -1';
data want;
infile ls;
input <whatever you want from the input>; call symputx('myfile',<the variable you read>);
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Exactly what I needed. Works perfectly! thanks!