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!
Thanks
Margaret
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;
run;
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?
Best,
Margaret
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?
I think that you may be looking for, as one way,
ods pdf; proc sql; select * from dictionary.columns where libname='IN' ; quit; 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.
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 25. Read more here about why you should contribute and what is in it for you!
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.