1# a2zhou
"应该是使用循环控制语句来写,因为实际我的数据不止5组有1百多组,不可能一个一个搞,谢谢了!!!"
In this case you don't need any loops, instead using the "by statement in the proc reg" as in following example.
***use by statement in proc reg will have a regression eq for each by level;
***it will run much faster than macro approach as otherone proposed;
***generated data with 5 group;
data tmp;
do i=1 to 1000;
index=ceil(ranuni(12345)*5);
x=rannor(12345);
y=1+2*x+rannor(12345);
output;
end;
drop i;
run;
proc sort data=tmp; by index;
run;
proc reg data=tmp;
by index;
model y=x;
run;
quit;