How to list all member types in a directory and the corresponding attributes and save in a sas data set ?
Have a look at SASHELP.VCOLUMN, this holds all the variables of each dataset in all libraries. There is also SASHELP.VTABLE which holds the dataset information. These are the same as DICTIONARY.* in SQL.
Hi,
Thanks for the useful information, but i am seeking the members of system directory not only SAS.
In other words if i have a list of excel files or word documents etc... how to capture all those files in a sas dataset with the DOS attributes (name,date modified,type,size etc....)
Thanks again.
Either use the x statement or call system routine to execute dir directory > somefile.lst, and then read from somefile.lst, or use
filename oscmd pipe "dir directory";
data listing;
infile oscmd truncover;
input dirline $1024.;
run;
Be aware that all this may not work when SAS operates under the -noxcmd commandline option.
Thanks for this approach.
After running the above code, a listing of the different members were collected as line records.
Hence a search is required to determine the required factor.
Got it.
What is it your trying to get, give specific examples? There are many options that you can put on the directory command, in your command prompt window, type dir /? and you will see them. Yes, if you want lots of information then you will need to parse the incoming string, it is not however particularly difficult, substr(1,first blank gives filename, then drop that, then to next blank gives size etc.
You can can use the External files functions to determine this. DOPEN,DOPTNUM,DOPTNAME , FOPEN, FOPTNAME, FOPTNUM to get directory and file information.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: