I am trying to build linear regression model for all the combination of variable. Ex: If y=c+x1+x2+x3, then I want to build model using the independent variable: X1 X2 X3 X1 X2 X1 X3 . . X1 X2 X3. I have written the code to generate all the possible combination of variable and now trying to pass each combination in the proc reg, But I am not able to do so. My aim is to automate the whole code in such a way that if i change the model input data the code automatically generate all the possible model. Code I have done : DATA model_data; input y1 x1 x2 x3; cards; 2 2 4 5 2 3 4 6 4 5 6 7 3 4 7 8 6 8 9 3 run; options mprint; %macro reg(comb_no=,ar_pos=); data vars&comb_no (keep=v1-v&comb_no); array v(2:6) $4 ('X_t' 'X_t1' 'X_t2' 'Y_t1','Y_t2'); ncomb=comb(5,&comb_no); do j=1 to ncomb; call lexcomb(j, &comb_no, of v(*)); put (v1-v&ar_pos) ($5.); output; end; call symputx('regs',ncomb); run; %mend reg; *also have to form a loop so that it calls the macro 5 times in a single do loop. data _null_; %reg(comb_no=1,ar_pos=1); %reg(comb_no=2,ar_pos=2); %reg(comb_no=3,ar_pos=3); %reg(comb_no=4,ar_pos=4); %reg(comb_no=5,ar_pos=5); run; proc print data=work.conc; run; data all (keep=full); set conc; full=catx(' ',v1,v2,v3,v4,v5); run; proc print data=work.all; run; data v1; set all (firstobs=1 obs=1); run; data m_data; set work.ts_data (keep=Y_t X_t); run; proc reg data=m_data plots=none; model Y_t = X_t; run;
... View more