Very Basic: %let var = “select all available”
Posted: 16 July 2015 10:06 PM   [ Ignore ]
Newbie
Rank
Total Posts:  6
Joined  2015-07-01

Hi,

I have a macro that select a few GVKEY from Compustat:
%let glist = ‘006066’ ‘012141’ ‘014489’;

Now I would like to keep the macro to keep the code as flexible as possible BUT select all GVKEY available in the WRDS databbase. What is the syntax? Sorry it is very basic…

Profile
 
 
Posted: 18 July 2015 08:57 AM   [ Ignore ]   [ # 1 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  901
Joined  2011-09-19

hi,

It is not very basic smile

Something like this (not tested) using macro %IF statement

%macro mymacro(dsout=, vars=, fyear1=, fyear2=, glist=);

data &dsout;
set comp.funda (keep= &vars;);
where 
/* include gvkey in.. only if glist is passed in macro call */
%if &glistne "" %then %do 
  
gvkey in (&glist;) and
%
end;
/* always include this */
fyear between &fyear1; and &fyear2;
if 
indfmt='INDL' and datafmt='STD' and popsrc='D' and consol='C';

%
mend;

/* without glist (all firms) */
%mymacro(dsout=mydatavars=at ceqfyear1=2000fyear2=2014);

/* with glist (some firms) */
%mymacro(dsout=mydatavars=at ceqfyear1=2000fyear2=2014glist=‘006066’ ‘012141’ ‘014489’); 

Hope this helps,

Joost

 Signature 

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

Profile