BookmarkSubscribeRSS Feed
Fluorite | Level 6

Hello SAS community,


I have a bunch of datasets from a study visit that have not yet been merged with the master data as the data is not yet complete and some of the datasets will be updated. Meanwhile, investigators would like to carry out analyses on what is available.


I put all the latest datasets in a folder called datain and ran the following SAS code which gave me almost what I wanted -

libname in "C:\temp\datain";
libname library "C:\temp\datain\Fmt";
OPTIONS FMTSEARCH=(library.formats);

ods pdf;
proc contents data = in._ALL_ varnum ; run;
ods pdf close;


In the output from proc contents, I would also like to see a column with the dataset name - the same one that appears at the top of each dataset proc contents, e.g. if he data is demographics, then demographics would appear in that column.


Is there an easy way to do that?

Would appreciate any help!





Super User Tom
Super User

Why not just give them the output DATASET from PROC CONTENTS instead?

So something like this:

proc contents data = in._ALL_ out=contents NOPRINT; run;

proc print data=contents;
var libname memname varnum name type length format label;
Fluorite | Level 6

Thanks Tom, that's really helpful


proc contents data = in._ALL_ varnum ; run;


With this, I get the proc contents by dataset in one output

I just want to add the dataset name, e.g. for the dataset demographics, I want exactly what comes out of 


proc contents data = in._ALL_ varnum ; run; + memname (the dataset name)

How can I do that?




Super User Tom
Super User

I have no idea what you are asking for. The information on what variables are in the datasets will be in the dataset output by PROC CONTENTS.  Can't you just create whatever report you want from that dataset?

Super User

I think that you may be looking for, as one way,


ods pdf;

proc sql;
  select *
  from dictionary.columns
  where libname='IN'
ods pdf close;

The dictionary.columns is one way when using Proc Sql to reference the data view SAS maintains with the properties of the variables of all the data sets in all the libraries. The LIBNAME, library name, and MEMNAME, member name i.e. data set name, are stored as all upper case letters so use upper case to find the ones you want.



Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.


Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 3 in conversation