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

Hi All,

 

I've just started learning SAS and im using EG. I was wondering is there a way of copying all of the table names in a SAS library and pasting it into another platform (excel, word, notepad etc.). Very primitive question I know but I'm looking to create a document that details what is in each table and why I would use it. It would be a lot easier if i could copy all the names at once rather than right them manually.

 

Apologies if this is posted on the incorrect board.

 

Many Thanks,

Barry

1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26
proc print data=sashelp.vtable;
  where libname="YOURLIB";
var memname; run;

The above will print to the output window all the tables names which you can then copy to whichever output. This is probably the easiest.

View solution in original post

6 REPLIES 6
RW9
Diamond | Level 26 RW9
Diamond | Level 26
proc print data=sashelp.vtable;
  where libname="YOURLIB";
var memname; run;

The above will print to the output window all the tables names which you can then copy to whichever output. This is probably the easiest.

Kurt_Bremser
Super User
proc sql;
select memname from dictionary.tables
where libname = "YOURLIB" ;
quit;

You can copy/paste the result.

Or you use "create table as" in the SQL and export the resulting dataset.

ballardw
Super User

And for the possibly confused new SAS user looking at @Kurt_Bremser's and @RW9's solutions:

 

SASHELP.VTABLE is a data view and the Dictionary.tables is a special reference Proc SQL can use to look at that data view. It is the same thing, just referenced in two different manners.

 

And another option:

 

proc datasets library=yourlib memtype=data;

quit;

 

Or use ODS to send the output to desired file:

 

ods rtf file="drive:\path\datasets.rtf";

proc datasets library=yourlib memtype=data;

quit;

ods close;

to send the results to a word processing document at the drive and path you specify.

Kurt_Bremser
Super User

Actually, dictionary.tables is a virtual table created at runtime (by proc sql reading the files!) that is available only in proc sql. sashelp.vtable is a SQL view of this table.

Using dictionary.tables instead of sashelp.vtable can improve performance when you have a lot of libraries assigned with lots of datasets/views in them, as using it directly enables SQL to do a better optimization of the where condition. At least in my experience.

bjlav90
Fluorite | Level 6

Many thanks both, I believe both answers were great solutions.

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 1666 views
  • 0 likes
  • 4 in conversation