BookmarkSubscribeRSS Feed
Trancho
Calcite | Level 5

How to list all member types in a directory and the corresponding attributes and save in a sas data set ?

6 REPLIES 6
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

Trancho
Calcite | Level 5

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.

Kurt_Bremser
Super User

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.

Trancho
Calcite | Level 5

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.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

ballardw
Super User

You can can use the External files functions to determine this. DOPEN,DOPTNUM,DOPTNAME , FOPEN, FOPTNAME, FOPTNUM to get directory and file information.

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 2095 views
  • 6 likes
  • 4 in conversation