BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
gsnidow
Obsidian | Level 7

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

1 ACCEPTED SOLUTION

Accepted Solutions
MikeZdeb
Rhodochrosite | Level 12

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...")

View solution in original post

4 REPLIES 4
Linlin
Lapis Lazuli | Level 10

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.

MikeZdeb
Rhodochrosite | Level 12

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...")

Haikuo
Onyx | Level 15

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

gsnidow
Obsidian | Level 7

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

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!

What is Bayesian Analysis?

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.

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