-
Notifications
You must be signed in to change notification settings - Fork 0
/
W6.txt
81 lines (71 loc) · 2.26 KB
/
W6.txt
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*Construct the RW forecasts for year t+1 and t+2
Construct the MV forecasts for year t+1 using earnings in the past two years
Find out which model is more accurate in predicting EPS for year t+1*/
PROC SORT DATA=ACX.EPS OUT=EPS; BY GVKEY FYEAR;
DATA EPS1; SET EPS; BY GVKEY FYEAR;
GVKEY1=LAG(GVKEY); FYEAR1=LAG(FYEAR); EPS1=LAG(EPS);
GVKEY2=LAG2(GVKEY); FYEAR2=LAG2(FYEAR); EPS2=LAG2(EPS);
IF GVKEY=GVKEY1 AND FYEAR=FYEAR1+1 THEN DO;
RW1=LAG(EPS); ERROR_RW1=ABS((EPS-EPS1)/EPS);
END;
IF GVKEY=GVKEY1=GVKEY2 AND FYEAR=FYEAR1+1=FYEAR2+2 THEN DO;
RW2=EPS2; MV2=(EPS1+EPS2)/2;
ERROR_RW2=ABS((EPS-RW2)/EPS);
ERROR_MV2=ABS((EPS-MV2)/EPS);
END;
PROC PRINT DATA=EPS1 (OBS=50); RUN;
PROC MEANS DATA=EPS1 N MEAN MEDIAN MIN MAX MAXDE=2;
VAR ERROR_RW1 ERROR_RW2 ERROR_MV2;
RUN;
PROC SQL;
CREATE TABLE EPS2
AS SELECT DISTINCT A.GVKEY, A.FYEAR, A.EPS,
B.EPS AS RW1, ABS((A.EPS-B.EPS)/A.EPS) AS ERROR_RW1,
C.EPS AS RW2, (B.EPS+C.EPS)/2 AS MV2,
ABS((A.EPS-C.EPS)/A.EPS) AS ERROR_RW2,
ABS((A.EPS-(B.EPS+C.EPS)/2)/A.EPS) AS ERROR_MV2
FROM ACX.EPS AS A, ACX.EPS AS B, ACX.EPS AS C
WHERE A.GVKEY=B.GVKEY=C.GVKEY AND A.FYEAR=B.FYEAR+1=C.FYEAR+2;
QUIT;
PROC PRINT DATA=EPS2 (OBS=50); RUN;
PROC MEANS DATA=EPS2 N MEAN MEDIAN MIN MAX MAXDEC=2;
VAR ERROR_RW1 ERROR_RW2 ERROR_MV2;
RUN;
/*PROC MEANS
CLM CSS CV KURTOSIS LCLM MAX MEAN MEDIAN(P50) MIN MODE N NMISS
P1 P5 P10 P90 P95 P99 PROBT Q1(P25) Q3(P75) QRANGE RANGE
SKEWNWSS(SKEW) STDDEV(STD) STDERR SUM SUMWGT T UCLM USS VAR*/
PROC MEANS DATA=ACX.EPS N MIN P1 P5 P10 Q1 MEDIAN MEAN Q3 P90 P95 P99 MAX MAXDEC=2 ;
VAR EPS;
RUN;
PROC SORT DATA=ACX.EPS OUT=EPS; BY FYEAR;
PROC MEANS DATA=EPS NOPRINT;
VAR EPS;
BY FYEAR;
OUTPUT OUT=EPS_YR MEAN=MEAN_EPS MEDIAN=MEDIAN_EPS N=FIRMS;
RUN;
PROC PRINT DATA=EPS_YR; RUN ;
/*PROC UNIVARIATE*/
CIBASIC
ALPHA=p
MU0=n
NORMAL
PLOTS
NOPRINT
TRIMMED=value
/*trimming the 1% of extreme values. */
PROC UNIVARIATE DATA=ACX.EPS TRIMMED=0.01;
VAR EPS;
RUN;
PROC UNIVARIATE DATA=ACX.EPS;
WHERE EPS BETWEEN -10 AND 10;
VAR EPS;
HISTOGRAM EPS / MIDPOINTS=0 TO 1 BY 1;
RUN;
PROC UNIVARIATE DATA=EPS MU0=0.5; VAR EPS; RUN;
PROC TTEST DATA=EPS H0=0.5; VAR EPS; RUN;
PROC TTEST DATA=EPS ;
WHERE FYEAR IN (2018, 2019) AND EPS BETWEEN -10 AND 10;
CLASS FYEAR ;
VAR EPS;
RUN;