-
Notifications
You must be signed in to change notification settings - Fork 21
/
sue.sas
67 lines (63 loc) · 3.06 KB
/
sue.sas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/***********************************************************************************************/
/* Program : SUE.sas */
/* Author : Denys Glushkov, WRDS */
/* Date Created : Feb 2008 */
/* Last Modified: Jun 2009 */
/* */
/* Description: 3 Methods of calculating standardized earnings surprises */
/* */
/* Macro SUE calculates standardized earnings surprises using 3 (three) methods considered */
/* by LM (2006). Method 1 assumes a rolling seasonal random walk model. Method 2 excludes */
/* "special items" from the Compustat Data. In these two methods, if most analyst forecasts of */
/* EPS are based on diluted (primary) EPS, Macro uses Compustat's diluted (basic) figures */
/* Method 3 is based solely on IBES median estimates/actuals and does not use Compustat data */
/***********************************************************************************************/
%MACRO SUE (method=, input=);
/* Process Compustat Data on a seasonal year-quarter basis*/
%local i;
%do i=1 %to 4;
proc sort data=&input (where=(fqtr=&i)) out=qtr;
by gvkey fyearq fqtr;
run;
data qtr; set qtr;
by gvkey fyearq;
%if &method=1 %then
%do;
lageps_p=lag(epspxq);lageps_d=lag(epsfxq);lagadj=lag(ajexq);
if first.gvkey then do; lageps_p=.;lageps_d=.;lagadj=.;end;
select (basis);
when ('P') do; actual=epspxq/ajexq; expected=lageps_p/lagadj;end;
when ('D') do; actual=epsfxq/ajexq; expected=lageps_d/lagadj;end;
otherwise do; actual=epspxq/ajexq; expected=lageps_p/lagadj;end;
end;
drop lageps_p lageps_d lagadj;
deflator=prccq/ajexq;
%end;%else;
%if &method=2 %then
%do;
lageps_p=lag(epspxq);lagshr_p=lag(cshprq);lagadj=lag(ajexq);
lageps_d=lag(epsfxq);lagshr_d=lag(cshfdq);lagspiq=lag(spiq);
if first.gvkey then do; lageps_p=.;lageps_d=.;lagshr_p=.;
lagshr_d=.;lagadj=.;lagspiq=.;end;
select (basis);
when ('P') do; actual=sum(epspxq,-0.65*spiq/cshprq)/ajexq; expected=sum(lageps_p,-0.65*lagspiq/lagshr_p)/lagadj;end;
when ('D') do; actual=sum(epsfxq,-0.65*spiq/cshfdq)/ajexq; expected=sum(lageps_d,-0.65*lagspiq/lagshr_d)/lagadj;end;
otherwise do; actual=sum(epspxq,-0.65*spiq/cshprq)/ajexq; expected=sum(lageps_p,-0.65*lagspiq/lagshr_p)/lagadj;end;
end;
drop lageps_p lagshr_p lagadj lageps_d lagshr_d lagspiq;
deflator=prccq/ajexq;
%end;%else;
%if &method=3 %then
%do;
actual=act;
expected=medest;
deflator=prccq;
%end;
sue&method=(actual-expected)/deflator;
format sue&method percent7.4;
run;
proc append base=comp_final&method data=qtr;run;
proc sql; drop table qtr;quit;
%end;
proc sort data=comp_final&method; by gvkey fyearq fqtr;run;
%MEND;