%macro createout(fobs,lobs,id ) ;
data out&id ;
set ok(firstobs=&fobs obs=&lobs);
run;
%mend createout;
proc sort data=ok;
by id;
run;
data _null_;
set ok(where=(id is not missing));
by id;
retain fobs lobs;
if first.id then fobs=_n_;
if last.id then lobs=_n_;
else return;
if last.id then
call execute('%createout('||trim(put(fobs,8.)) ||','||trim(put(lobs,8.))||',' ||trim(put(id,8.)) ||')');
run;作者: shiyiming 时间: 2004-12-4 09:42 标题: 还要努力啊 我运行了一下你的程序。
结果好象不对。
比如,我的out2中的记录应该是一条id=2的记录
可是你的是缺失值。
你的out3里面是2
你的out5里面是3,5
....
这些都不符合条件
可能你还得想一下。作者: shiyiming 时间: 2004-12-4 09:58 标题: 想优化一下程序还没优化成,还是改回去吧 data _null_;
[u:618bb]set ok ;
if id ne . ;[/u:618bb]
by id;
retain fobs lobs;
if first.id then fobs=_n_;
if last.id then lobs=_n_;
else return;
if last.id then
call execute('%createout('||trim(put(fobs,8.)) ||','||trim(put(lobs,8.))||',' ||trim(put(id,8.)) ||')');
run;作者: shiyiming 时间: 2004-12-4 10:42 标题: 再等 嗯,对了。不过和我的做法不一样。
看来我们想法和思维方向还是有区别的
我最后的输出是在一个DATA步中完成的,所以要多两个技术难点。
呵呵,也好,多点经验。多了点认识。
再看看有没有别人用别的方法吧作者: shiyiming 时间: 2004-12-5 10:31 标题: 可否把您的程序贴一下 或者说一下技术难点在那里