Greetings all. I am needing to create a dataset with only the # and name values from the output of proc datasets. I've found lots of documents about proc contents and proc datasets, but I can't find specifically what I'm needing to do. If I run this...
proc datasets lib=OTBR;quit;run;
I see this in the log...
Member File
# Name Type Size Last Modified
1 ONTIMESUM0 DATA 5120 12Sep12:09:42:07
2 ONTIMESUM1 DATA 5120 12Sep12:09:42:14
3 ONTIMESUM2 DATA 5120 12Sep12:09:42:20
4 ONTIMESUM3 DATA 5120 12Sep12:09:42:26
5 ONTIMESUM4 DATA 5120 12Sep12:09:42:34
What I need to do is capture the first two columns only from this output into a dataset in the same library. I'm not sure if I should use proc contents or proc datasets. Does anyone have any ideas? Thank you.
Greg
hi ... I think that you want names of data sets and views (not variables within a data set), so you could try ...
proc sql;
create table datasets as
select memname as NAME, memtype as TYPE from dictionary.tables where libname eq 'SASHELP';
quit;
just use a libref on the new data set to put it in the correct location ("...output into a dataset in the same library...")
Greg,
example:
proc contents data=sashelp.class out=want (keep=varnum name) noprint;
run;
proc print data=want;run;
Sorry. I misundstood your question. I thought you wanted the variable names in a dataset.
hi ... I think that you want names of data sets and views (not variables within a data set), so you could try ...
proc sql;
create table datasets as
select memname as NAME, memtype as TYPE from dictionary.tables where libname eq 'SASHELP';
quit;
just use a libref on the new data set to put it in the correct location ("...output into a dataset in the same library...")
Hi,
There are many ways to obtain metadata information. Like Linlin suggested, proc contents being one. You can also directly retrieve info from dictionary tables/views. One example is (using Linlin's example):
proc sql;
create table want as
select varnum,name from dictionary.columns where lIBNAME='SASHELP' AND MEMNAME='CLASS';QUIT;
Haikuo
Thank you all for the tips. I did not think of using proc sql to hit the system tables directly. As SQL is my native language, that option is easiest for me. Thanks again.
Greg
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.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.