全部版块 我的主页
论坛 计量经济学与统计论坛 五区 计量经济学与统计软件
2474 2
2005-09-19

I have a dataset that has three variables, say y, x and group. I need to do regression of y on x within each group, and output the predicted along with variables y, x, groups into one dataset. If there are only two groups, I can do it like:

proc reg data=a; where group=1; Model y= x; OUTPUT out=c1 P=PRED ; run; quit;

proc reg data=a; where group=2; Model y= x; OUTPUT out=c2 P=PRED ; run; quit; data combine; set c1 c2; run; But in fact I have 200 groups, I am asking if there is an easy & smart way to do that?

Thanks

Dale

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2005-9-19 07:16:00

PROC REG ....; BY GROUP; RUN;

WenSui Liu (http://statcompute.blogspot.com) Senior Decision Support Analyst Cincinnati Children Hospital Medical Center

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2005-9-19 07:20:00

The easy AND smart way to do this is by using the BY-processing features of SAS. I'm putting a PROC SORT in here, in case the data are not sorted on GROUP first. BY-processing needs that. proc sort data=a;

by group;

run;

proc reg data=a; by group; model y= x; output out=c2 P=PRED ; Now you have the regressions done separately, by group. BUT you don't have any regression diagnostics or anything, and you have 200 (or so) regressions to grapple with. Are you sure that you are ending up with a good solution from a statistical point of view? Are you sure that your results are meaningful, if you have no checks for outliers or leverage points or non-linearity? Are you sure that your output will be helpful, when 200 separate tests, all at alpha=0.05, would have about 10 apparently significant results just by chance even if the null hypotheses were true? How will you separate out the specious significant value from the real ones? I think you have a host of potential statistical problems awaiting you. You may want to write back to SAS-L and explain more fully what you are trying to achieve in the big picture here. HTH, David -- David L. Cassell mathematical statistician Design Pathways 3115 NW Norwood Pl. Corvallis OR 97330

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群