BookmarkSubscribeRSS Feed
Calcite | Level 5

Hi All,


I am running the a firm fixed effect regression to find the residual, but the error message says my CLASS variable has only one level.


My regression has only one independent variable which I call it 'independent_variable_TACC', and the dependent variable is 'dependent variable_BTD'. I used PROC REG to get residuals before by adding a '/r' after MODEL command, but it seems like PROC GLM does not work in that way. I attached my codes herewith. I am not sure if I need to add both firm_code (gvkey) and year (fyear) in CLASS or only firm_code is needed.


Can anyone tell me how do I get the residual from a firm fixed effect regression? I really appreciate for any help with this problem. Thanks a lot in advance.



proc glm data=rep.DD_BTD_regression;
class gvkey fyear; /*firm fixed effect*/
model dependent_variable_BTD=independent_variable_TACC; 
by gvkey fyear;
output out=rep.DD_BTD_residuals /*new data set with residual*/
      r=DD_BTD_resid; /*the residual I need*/



Best regards,





Diamond | Level 26

You have class variables that are not in the model. Delete the CLASS statement, try it again.




Add the class variables into the model, and get rid of the BY statement, try it again.

Paige Miller



Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Get the $99 certification deal.jpg



Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 2 in conversation