i'm using 2sls to estimate my model which contains 7 dependent variables: Y1,Y2,Y3,Y4,Y5,Y6,Y7. There is no problem to run the code, however, i want to save the residuals from these estimations, and i want to find the pairwise residual correlations of these residuals and print them out. how can i code this into the proc model ?
here is my code:
Proc model data=main;
Y1=a0+a1*lag(Y1)+
a5*(W1_2*Y2 + W1_3*Y3 + W1_4*Y4 + W1_5*Y5 + W1_6*Y6 +W1_7*Y7)+
a6*lag(W1_2*Y2 + W1_3*Y3 + W1_4*Y4 + W1_5*Y5 + W1_6*Y6 +W1_7*Y7)+
a7*lag2(W1_2*Y2 + W1_3*Y3 + W1_4*Y4 + W1_5*Y5 + W1_6*Y6 +W1_7*Y7)+
a8*lag3(W1_2*Y2 + W1_3*Y3 + W1_4*Y4 + W1_5*Y5 + W1_6*Y6 +W1_7*Y7) +
a9*lag4(W1_2*Y2 + W1_3*Y3 + W1_4*Y4 + W1_5*Y5 + W1_6*Y6 +W1_7*Y7);
Y2=b0+b1*lag(Y2)+
b5*(W2_1*Y1 + W2_3*Y3 + W2_4*Y4 + W2_5*Y5 + W2_6*Y6 + W2_7*Y7)+
b6*lag(W2_1*Y1 + W2_3*Y3 + W2_4*Y4 + W2_5*Y5 + W2_6*Y6 + W2_7*Y7)+
b7*lag2(W2_1*Y1 + W2_3*Y3 + W2_4*Y4 + W2_5*Y5 + W2_6*Y6 + W2_7*Y7)+
b8*lag3(W2_1*Y1 + W2_3*Y3 + W2_4*Y4 + W2_5*Y5 + W2_6*Y6 + W2_7*Y7)+
b9*lag4(W2_1*Y1 + W2_3*Y3 + W2_4*Y4 + W2_5*Y5 + W2_6*Y6 + W2_7*Y7);
Y3=c0+c1*lag(Y3)+
c5*(W3_1*Y1 + W3_2*Y2 + W3_4*Y4 + W3_5*Y5 + W3_6*Y6 + W3_7*Y7)+
c6*lag(W3_1*Y1 + W3_2*Y2 + W3_4*Y4 + W3_5*Y5 + W3_6*Y6 + W3_7*Y7)+
c7*lag2(W3_1*Y1 + W3_2*Y2 + W3_4*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Y7)+
f7*lag2(W6_1*Y1 + W6_2*Y2 + W6_3*Y3 + W6_4*Y4 + W6_5*Y5 + W6_7*Y7)+
f8*lag3(W6_1*Y1 + W6_2*Y2 + W6_3*Y3 + W6_4*Y4 + W6_5*Y5 + W6_7*Y7)+
f9*lag4(W6_1*Y1 + W6_2*Y2 + W6_3*Y3 + W6_4*Y4 + W6_5*Y5 + W6_7*Y7);
Y7=g0+g1*lag(Y7)+
g5*(W7_1*Y1 + W7_2*Y2 + W7_3*Y3 + W7_4*Y4 + W7_5*Y5 + W7_6*Y6)+
g6*lag(W7_1*Y1 + W7_2*Y2 + W7_3*Y3 + W7_4*Y4 + W7_5*Y5 + W7_6*Y6)+
g7*lag2(W7_1*Y1 + W7_2*Y2 + W7_3*Y3 + W7_4*Y4 + W7_5*Y5 + W7_6*Y6)+
g8*lag3(W7_1*Y1 + W7_2*Y2 + W7_3*Y3 + W7_4*Y4 + W7_5*Y5 + W7_6*Y6)+
g9*lag4(W7_1*Y1 + W7_2*Y2 + W7_3*Y3 + W7_4*Y4 + W7_5*Y5 + W7_6*Y6);
endogenous Y1-Y7;
exogenous W1_2-W1_7 W2_1 W2_3-W2_7 W3_1 W3_2 W3_4-W3_7 W4_1-W4_3 W4_5-W4_7
W5_1-W5_4 W5_6-W5_7 W6_1-W6_5 W6_7 W7_1-W7_6;
instruments y1_1-y1_4 y2_1-y2_4 y3_1-y3_4 y4_1-y4_4 y5_1-y5_4 y6_1-y6_4
y7_1-y7_4;
parms a0 a1 a5-a9 b0 b1 b5-b9 c0 c1 c5-c9 d0 d1 d5-d9 e0 e1 e5-e9 f0 f1 f5-f9 g0 g1 g5-g9;
range nyear= 1996.1 to 2017.4;
fit Y1-Y7/2sls outest=eat1.est1;
run;
Have you looked at the FIT statement documentation? I see an "outresid=" parameter that makes a dataset of residuals, which you can then submit to proc corr.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.
Find more tutorials on the SAS Users YouTube channel.