This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Macro that creates a dataset with Compustat, CRSP and IBES identifiers (gvkey, permno, Ibes ticker) | |
for fiscal years in period start-end. | |
macro parameters: | |
@dsout: name of dataset to create | |
@start: start year | |
@end: end year | |
@compvars: list of variables to get from compustat, default value: at sale ceq ni | |
@minscore: ibes iclink minimum score (0 [default] is best score, 6 worst, see iclink.sas) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/***************************************** | |
Author unknown - that is a pity because this macro is the best since sliced bread! | |
Trim or winsorize macro | |
* byvar = none for no byvar; | |
* type = delete/winsor (delete will trim, winsor will winsorize; | |
*dsetin = dataset to winsorize/trim; | |
*dsetout = dataset to output with winsorized/trimmed values; | |
*byvar = subsetting variables to winsorize/trim on; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%MACRO ARRAY(arraypos, array=, data=, var=, values=, | |
delim=%STR( ), debug=N, numlist=Y); | |
/* last modified 8/4/2006 a.k.a. MACARRAY( ). | |
72nd col -->| | |
Function: Define one or more Macro Arrays | |
This macro creates one or more macro arrays, and stores in them | |
character values from a SAS dataset or view, or an explicit list | |
of values. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Earnings management models | |
Author: Joost Impink, March 2016 | |
Models estimated: | |
- Jones model, tac = a0 + a1 1/TAt-1 + a2chSales + a3PPE + a4ROA + error. | |
- variable names DA_Jones ABSDA_Jones | |
- Modified Jones model, as Jones model, but using chSales - chREC to compute fitted values. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## For each SEC filing stock return in the interval [time - before, time + after] is measured | |
# Set constants | |
before <- 0 | |
after <- 7200 | |
# load Grokit Nanex library | |
library(gtNanex) | |
# Load dataset with 8-K filings (symbol and timestamp)s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* We need to make a sample for US listed firms with fiscal years 1962-1990 | |
From Compustat Funda we need: | |
- gvkey Firm identifier | |
- datadate End of fiscal year | |
- fyear Fiscal year | |
- epspx EPS before extraordinary items | |
- prcc_f Price at fiscal year end | |
- csho Common shares outstanding end of year (to compute market cap) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Table 1 | |
Left panel shows by year the #obs, and the #loss years | |
Right panel shows the same, but for firms that were in the sample from 1968 | |
through 1990 (23 years) | |
*/ | |
/* Left panel */ | |
/* Using SQL */ | |
proc sql; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Table 2 | |
Use firms that have at least 8 years of data | |
Count the number of loss-years | |
*/ | |
/* For each gvkey, count the #loss-years */ | |
proc sql; | |
create table d_table2_a as | |
select gvkey, sum(loss) as lossYears from b_sample | |
/* gvkey must be in the following table */ | |
where gvkey IN ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* For each size decile: compute #firm-years and #losses */ | |
/* Create size deciles */ | |
proc rank data = b_sample out = e_ranked groups = 10; | |
var size; | |
ranks size_d ; | |
run; | |
/* Add 1 to rank (0-9 => 1-10) */ | |
data e_ranked; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Regressions */ | |
/* Some variables need to be created */ | |
data g_sample; | |
set b_sample; | |
/* earnings per share scaled by beginning of year stock price */ | |
e_p = epspx / prcc_f_lag; | |
/* change in eps scaled by boy stock price */ | |
ch_e_p = (epspx - epspx_lag) / prcc_f_lag; | |
/* keep observations with no missings */ |
OlderNewer