BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
TerryC
Calcite | Level 5

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;
ADA = abs(tac-tac_pdt);
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!

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

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.

View solution in original post

1 REPLY 1
Kurt_Bremser
Super User

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.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 2754 views
  • 1 like
  • 2 in conversation