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
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.
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.
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.
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.
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.
I moved the thread to the Enterprise Guide community.
Many thanks both, I believe both answers were great solutions.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.