Solved
New Contributor
Posts: 3

# Discretionary Accruals SAS Code Question

Hi, I am a SAS beginner, and trying to figure out the SAS code for discretionary accruals. I borrowed some SAS code from http://codegists.com/snippet/sas/earnings_management_modelssas_joostimpink_sas.

First, I construct all variables and winsorize them. Then I use the following code to calculate the discretionary accruals.

/* Regression by industry-year
edf + #params (4) will equal the number of obs (no need for proc univariate to count) */
proc sort data=Da.Da2_winsor; by fyear sic2;run;
proc reg data=Da.Da2_winsor noprint edf outest=Da.Da2_parms;
model wtac = wdrev wppe wroa; /* Kothari with ROA in model */
by fyear sic2;
run;

Data Da.Da2_parms; Set Da.Da2_parms;
rename wdrev=wdrev_parm wppe=wppe_parm wroa=wroa_parm;
Run;

*To merge the parameters into the main dataset;
Proc sql;
Create table Da.Da3 as select *
from Da.Da2_winsor as a left join Da.Da2_parms as b
on a.fyear=b.fyear and a.SIC2=b.SIC2;
Quit;

Data Da.Da3; Set Da.Da3;
tac_pdt = intercept + wdrev*wdrev_parm + wppe*wppe_parm + wroa*wroa_parm;
Run;

The results of this SAS code are close to the results from a paper, but there are still some difference. I do not know whether this difference is from some errors of the code. I have two questions:

1. I wonder if the codes above look right.

2. Does the the following SAS code give us the parameters and the intercepts for regressions of different years and different industries?

/* Regression by industry-year
edf + #params (4) will equal the number of obs (no need for proc univariate to count) */
proc sort data=Da.Da2_winsor; by fyear sic2;run;
proc reg data=Da.Da2_winsor noprint edf outest=Da.Da2_parms;
model wtac = wdrev wppe wroa; /* Kothari with ROA in model */
by fyear sic2;
run;

Thank you!

Accepted Solutions
Solution
‎07-18-2017 09:23 PM
Super User
Posts: 7,762

## Re: Discretionary Accruals SAS Code Question

I moved your question to the SAS STAT community, as it is mainly about proc reg.

As advice for the beginner: give your code visual structure, this makes it easier to read, understand and maintain:

``````/* Regression by industry-year
edf + #params (4) will equal the number of obs (no need for proc univariate to count) */

proc sort data=Da.Da2_winsor;
by fyear sic2;
run;

proc reg
data=Da.Da2_winsor
noprint
edf
outest=Da.Da2_parms
;
model wtac = wdrev wppe wroa; /* Kothari with ROA in model */
by fyear sic2;
run;``````

Also note that I posted the code using the "little running man" (7th) icon, which invokes a fixed-font window that does format code close to what the enhanced editor in SAS does.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers

All Replies
Solution
‎07-18-2017 09:23 PM
Super User
Posts: 7,762

## Re: Discretionary Accruals SAS Code Question

I moved your question to the SAS STAT community, as it is mainly about proc reg.

As advice for the beginner: give your code visual structure, this makes it easier to read, understand and maintain:

``````/* Regression by industry-year
edf + #params (4) will equal the number of obs (no need for proc univariate to count) */

proc sort data=Da.Da2_winsor;
by fyear sic2;
run;

proc reg
data=Da.Da2_winsor
noprint
edf
outest=Da.Da2_parms
;
model wtac = wdrev wppe wroa; /* Kothari with ROA in model */
by fyear sic2;
run;``````

Also note that I posted the code using the "little running man" (7th) icon, which invokes a fixed-font window that does format code close to what the enhanced editor in SAS does.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
☑ This topic is solved.

Discussion stats