data bb (rename=(y=a)) cc(rename=(y=b));
set aa;
if mod(_n_,2)=1 then output bb;
else if mod(_n_,2)=0 then output cc;
run;
data bb;
set bb;
n=_n_;
run;
data cc;
set cc;
n=_n_;
run;
data dd(keep=a b);
merge bb cc;
by n;
run;
proc print data=dd;
run;
[/code:b2yimgn3]作者: shiyiming 时间: 2011-6-18 12:56 标题: Re: 数据集观测的选择问题 非常感谢!作者: shiyiming 时间: 2011-6-20 09:59 标题: Re: 数据集观测的选择问题 data b;
do i=1 to tot;
set a nobs=tot point=i;
if mod(a,2) then x=b;else y=b;
if i=tot and mod(tot,2) then y=.; /*假设有奇数行,则最后一个Y置为缺失*/
if mod(i,2)=0 or (i=tot and mod(tot,2)) then output; /*两个一组输出或者是有奇数行,则输出最后一行*/
end;
stop;
keep x y;
run;