Desktop productivity for business analysts and programmers

Copy All table names from EG to another document

Accepted Solution Solved
Reply
New Contributor
Posts: 2
Accepted Solution

Copy All table names from EG to another document

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


Accepted Solutions
Solution
‎05-17-2018 10:51 AM
Super User
Super User
Posts: 9,840

Re: Copy All table names from EG to another document

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


All Replies
Solution
‎05-17-2018 10:51 AM
Super User
Super User
Posts: 9,840

Re: Copy All table names from EG to another document

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.

Super User
Posts: 10,574

Re: Copy All table names from EG to another document

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.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Super User
Posts: 13,941

Re: Copy All table names from EG to another document

Posted in reply to KurtBremser

And for the possibly confused new SAS user looking at @KurtBremser'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.

Super User
Posts: 10,574

Re: Copy All table names from EG to another document

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.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Super User
Posts: 10,574

Re: Copy All table names from EG to another document

I moved the thread to the Enterprise Guide community.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
New Contributor
Posts: 2

Re: Copy All table names from EG to another document

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

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 197 views
  • 0 likes
  • 4 in conversation