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

Hi all,

I want to run a regression between annual expense and sales, including a fixed effect for each firm (firm_code).

I came across the codes:

proc glm;

absorb firm_code;

model expense = sales / solution noint;

run;

quit;

However, I am using a panel data including 4 years of observations for each firm. This means for each firm (firm_code) there will be four observations of expense and sales.

As a result, I only need to create on dummy variable for each firm, I am not sure whether the command "absorb" does that, or does it create a dummy variable for every line of observation for firm?

If there is any better ways of running fixed effects regression, please tell me Smiley Happy

Thank you in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
StatDave
SAS Super FREQ

Paul Allison has a wonderful book on fitting fixed effects models of various types - ordinary regression (normal response), logistic, Poisson, and survival (Cox) models. Here is the reference and a link to it:

 

Fixed Effects Regression Methods for Longitudinal Data Using SAS (Allison, P., SAS Institute, 2005)

View solution in original post

5 REPLIES 5
SteveDenham
Jade | Level 19

Actually, you don't have to create a dummy variable for each firm, just be certain that the dataset is sorted by firm_code.  GLM will automatically nest the observations within firm_code, and perform the regression.  And provided you don't need predicted values or regression diagnostics, you get all this with a marked reduction in overhead computational resources.

Now if you want a regression for EACH firm_code (sort of implied in the first line of your post), either a BY statement or something like:

proc glm;

class firm_code;

model model expense = sales|firm_code / solution noint;

quit;

This would give separate intercepts and slopes for each firm_code, but assumes common residual variance across firm_codes

Steve Denham

Message was edited by: Steve Denham

miguel_valero
Calcite | Level 5

Hi Steve,

Sorry for the misunderstanding. I have a panel of annual data for different firms over several years of time. I just need to run one regression for the entire panel. However, I do need to control for firm fixed effect for each individual firm (presumably by adding a dummy variable for each firm - e.g. dummy A equals to 1 for firm A 2010, 2011, and 2012).

Thank you for your help!

SteveDenham
Jade | Level 19

Then ABSORB looks like your best tool to accomplish that.

Steve Denham

omer2020
Obsidian | Level 7

@SteveDenhamCurrently I am doing exactly what you have mentioned. I am trying to run fixed effect regression. In first step I need to run regression on every firm-year (each year of each firm individually) and then using the intercept of that regression in second regression.

I tried to run your code:

proc glm;

class firm_code;

model model expense = sales|firm_code / solution noint;

quit;

 

I guess writing model two times was unintentional. So I change you codes as follow;

proc glm data=dtab2;
class count;                      * where count is unique number for each firm year;
model exret = Mktrf | count / solution noint;      *where exret=excess return, Mktrf=Market return;

output out=xglm p=predicted;
quit;

Results show this error

ERROR: Number of levels for some effects > 32767.

Also I tried to run proc reg/proc panel/proc tscs/ but the problem is:

if I don't specify by variable, I get reg output of whole model as one (row) observation having intercept and coefficient for all firms

if I specify by variable for both time series (macc=unique for each time obs) and cross-sectional (permno) variable, it seems my model is over specified,

  >proc reg give infinite error for each firm-year (number of nonmissing values are ....)

  >proc panel give error (Event Stack Underflow caused by mis-matched begin and end event call in SAS)

if I reg by count(proc reg data=dtab2 outest=xreg noprint; by count; model exret = Mktrf / adjrsq; quit;) then beta & RMSE ave no values and intercept are generated exactly of similar value as exret (dep variable) itself.

 

Kindly suggest me any solution to this problem.

 

 

StatDave
SAS Super FREQ

Paul Allison has a wonderful book on fitting fixed effects models of various types - ordinary regression (normal response), logistic, Poisson, and survival (Cox) models. Here is the reference and a link to it:

 

Fixed Effects Regression Methods for Longitudinal Data Using SAS (Allison, P., SAS Institute, 2005)

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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
  • 5 replies
  • 15339 views
  • 0 likes
  • 4 in conversation