turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- Analytics
- /
- Stat Procs
- /
- Discretionary Accruals SAS Code Question

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

07-13-2017 01:14 AM

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!

Accepted Solutions

Solution

07-18-2017
09:23 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

07-13-2017 02:38 AM

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

Maxims of Maximally Efficient SAS Programmers

All Replies

Solution

07-18-2017
09:23 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

07-13-2017 02:38 AM

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

Maxims of Maximally Efficient SAS Programmers