fyfzhdsfdx 发表于 2013-5-12 11:02 
谢谢您的即时回复,再问一下为什么
data raw; do x=1 to 30;output;end;group=int((_n_-1)/6);run;
这个 ...
1.output改变了data步默认的输出数据方式,在do--end循环中没有group的出现,自然就是默认为空值;当跳出这个循环后,x就变31,再执行group这个语句,此时_n_=1,group的值就为0,由于前面output的出现,所以这条记录不会输出数据集中,如果在group这句后面加上output就可以输出了
data raw;
do x=1 to 30;
output;
end;
group=int((_n_-1)/6);
output;
run;
2._N_ is initially set to 1. Each time the DATA step loops past the DATA statement, the variable _N_ increments by 1. The value of _N_ represents the number of times the DATA step has iterated.你改的这段code过程中data步循环只有一次,所以_n_一直都为1,为了达到效果,就只能采用下面这段code
data raw2;
set raw;
group=int( (_n_ - 1)/6);
run;