Get the variable (columns) list from a data base
Posted: 06 March 2012 12:57 PM   [ Ignore ]
Sr. Member
RankRankRankRank
Total Posts:  169
Joined  2011-09-20

This code will download all columns information from the compustat database on Wrds. Pretty neat if you need to search something on the column discription part.
A good alternative to the Research/search variables on Wrds website.

%let wrds = wrds.wharton.upenn.edu 4016;options comamid = TCP remote=WRDS;signon username=_prompt_;
rsubmit;

libname comp ‘/wrds/comp/sasdata/naa’;
proc sql noprint;
create table mytab as
select*
from DICTIONARY.COLUMNS
where UPCASE(libname) = “COMP”;
quit;
proc download data = mytab out = mytabs1;  run;
endrsubmit;

Credits go to Mark @ Wrds.
Thanks Mark!

Update:

data newtab;
set mytabs1;
str_search = find (label, “fips”,“i” );
if str_search >0 then output;
run;

*this code will search the “label” for any key words (such as fips).  I think this “label search function” is good to very useful for the variable name search.
*use the uppper case of the libname on WRDs server. lower case name like “comp” will not work.

 

 

 Signature 

Zenghui
A humble student of business

Profile
 
 
Posted: 06 March 2012 01:06 PM   [ Ignore ]   [ # 1 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  901
Joined  2011-09-19

interesting, thanks!

(just in case: here is the variable search page: http://wrds-web.wharton.upenn.edu/wrds/tools/variable_search.cfm )

 Signature 

To reply/post new questions: Please use the group WRDS/SAS on Google Groups! http://groups.google.com/d/forum/wrdssas

Profile