/******************************************************** obtain S&P 500 information through the WRDS System https://wrds-web.wharton.upenn.edu/wrds/research/applications/others/S%20and%20P%20500/index.cfm --------------------------------------------------------------------------------*/ %let wrds=wrds.wharton.upenn.edu 4016; options comamid=TCP remote=WRDS; signon username=_prompt_; rsubmit; options sasautos=('/wrds/wrdsmacros/', SASAUTOS) MAUTOSOURCE; *Use WRDS MACRO ,e.g. ICLINK ; endrsubmit; *********************************************************/ *Compustat: Get S&P 500 list by Compustat; rsubmit; proc sql; create table comp500 as select a.datadate, a.at, a.ib , a.fyear, a.tic , a.SICH, a.conm , b.gvkey, b.iid , b.from, b.thru from comp.funda ( where=(DATAFMT='STD' and INDFMT='INDL' and CONSOL='C' and POPSRC='D') ) as a, comp.idxcst_his (where=(gvkeyx='000003')) as b where (a.gvkey=b.gvkey) and (a.datadate >=b.from) and (a.datadate <=b.thru or missing(thru)=1) order by gvkey , datadate; quit; run; endrsubmit; *Print and Check; rsubmit; proc print data = comp500 ; where gvkey in ( '160329' ); run; proc contents data =comp500 ; run; endrsubmit; *Download ; rsubmit; proc download data = comp500; run; endrsubmit;