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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

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
  • 6 replies
  • 803 views
  • 6 likes
  • 4 in conversation