Hello Everyone, I am writing a SAS program where I get data from Compustat and CRSP in order to do an event study. I merged my CRSP stock return data with my CRSP market index return data with no issues. However, I am having issues merging my Compustat data with my CRSP data - for some reason, the match merge is not working, and it does not give me any error messages. Can someone please help me? Here is my SAS program - it uses remote connection to WRDS. The issue is with the match merge at the end - in red font color. /*Remote Sign-on to WRDS Server*/ %let wrds = wrds.wharton.upenn.edu 4016; options comamid=TCP remote=WRDS; signon username=_prompt_; rsubmit; *Tell SAS where to look for data on WRDS; *Define directory for Compustat North America - Monthly Update; libname compm '/wrds/comp/sasdata/nam'; data tem; set compm.fundq; if indfmt="INDL"; if consol="C"; if popsrc="D"; if datafmt="STD"; * Get Compustat data for the Dow Jones Industrial Avg. Components for 2000 to 2015; where 2000<=year(datadate)<=2015 and tic in ('AXP', 'AAPL', 'BA', 'CAT', 'CVX', 'CSCO', 'KO', 'DIS', 'DD', 'XOM', 'GE', 'GS', 'HD', 'IBM', 'INTC', 'JNJ', 'JPM', 'MCD', 'MMM', 'MRK', 'MSFT', 'NKE', 'PFE', 'PG', 'TRV', 'UNH', 'UTX', 'VZ', 'V', 'WMT'); Format cusip $8.; Keep cusip tic conm datadate datafqtr rdq epsfxq; Run; * Download the dataset from WRDS to local library; Proc sort data=tem; By cusip; Proc download data=tem out=cmpst_raw; Run; endrsubmit; rsubmit; *Define directory for CRSP - Monthly Update; libname daily '/wrds/crsp/sasdata/a_stock'; Data tem2; Set daily.dsf (keep = cusip date ret); * Get CRSP Daily stock return data for the Dow Jones Industrial Avg. components from 2000 to 2015. CUSIP is used since CRSP does not have ticker; where 2000<=year(date)<=2015 and cusip in ('02581610','88579Y10','03783310','09702310','14912310', '16676410','17275R10','89417000','38141G10','92826C83','59491810','93114210','91301710','91324P10', '74271810','71708110','65410610','58933Y10','58013510','47816010','45920010','45814010','43707610'); format date yymmddn8.; Run; Proc sort data = tem2; By date cusip; * Download the dataset from WRDS to local library; Proc download data=tem2 out=crsp_stk; Run; endrsubmit; rsubmit; libname ind '/wrds/crsp/sasdata/a_indexes'; * Get daily market index data for January 2000 to December 31, 2015; Data tem3; set ind.dsic (keep=caldt vwretd ewretd); Where '03Jan2000'd<=caldt<='31Dec2015'd; Format date yymmddn8.; Rename caldt=date; Run; Proc sort data = tem3; By date; Proc download data=tem3 out=crsp_indx; Run; endrsubmit; Data crsp_stk_indx; merge crsp_stk crsp_indx; By date; Run; Data crsp_stk_indx; set crsp_stk_indx; where cusip ne " " and vwretd ne .; * Remove records that have no CUSIP or no Mkt return data; Run; * Modify Compustat quarterly earnings file to calculate unexpected earnings based on previous earnings; Data cmpst_raw2; Set cmpst_raw; By cusip; If epsfxq and rdq; * Keep records where earnings and report date for quarterly earnings are not missing; ueps = epsfxq - lag(epsfxq); * UEPS is defined as the current earnings less prior qtr earnings; If ueps < 0 then evntdum=1; Else if ueps > 0 then evntdum=2; Else evntdum = 0; if first.cusip then ueps = 0; If ueps; * Keep records where UEPS does not equal to zero; keep cusip rdq epsfxq ueps evntdum; * Keep only CUSIP, Report date for quarterly earnings, earnings and UEPS; Run; * Create dates 90 days prior to event date (rdq) and 10 days after event date (rdq); data cmpst_int; Format date yymmddn8.; set cmpst_raw2; do date = rdq - 90 to rdq + 10; output; end; keep cusip date rdq evntdum; run; proc sort data=cmpst_int; by cusip date; run; Data crsp_stk_indx; Set crsp_stk_indx (keep = cusip date ret vwretd evntdum); Proc sort data = crsp_stk_indx; By cusip date; Run; Data crsp_stk_indx; Retain date cusip ret vwretd; set crsp_stk_indx; Run; Data crsp_cmpst; Merge cmpst_int (in=a) crsp_stk_indx (in=b); By cusip date; If a and b; Run; Thanks!
... View more