I'm new to SAS. I'm doing research for stock market, and I want to run a regression with fixed effect by industry and year at the same time(i.e: if there are four industry and ten years, I want to generate forty regression results for each industry in each year)
I run the code as following, which the result isn't what I want obviously.
/////
proc glm data=dac;
class industry year;
model y = x1 x2 x3 industry year / solution;
run;
quit;
/////
Is there any way to solve my problem?
I run the code as following, which the result isn't what I want obviously.
Since Industry and Year are class variables, you do get different intercepts for each industry/year combination, but the slopes of X1 X2 and X3 are constant. If you want different slopes for each industry/year combination:
model y = x1*industry*year x2*industry*year x3*industry*year/ solution;
That's one way to get the slopes for each industry/year combination, there are other MODEL statements that do the equivalent but are parameterized differently.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.