|
板凳

楼主 |
发表于 2004-12-4 04:03:53
|
只看该作者
考虑missing 和重复纪录可能要这样(如果能排序的话)
data ok;
input id;
cards;
2
5
6
5
9
.
9
3
;
run;
%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; |
|