紫月170 发表于 2017-12-8 14:56 
我还想再问一下,如果我的股票数据是按代码分组的,000001 一段000002一段....这样纵向连接的,这个循环分 ...
/*建立测试数据集*/
data test;
do daima=600001 to 600003;
do x=1 to 100;
output;
end;
end;
run;
%let y=6; /*在此设置每组的观测数*/
data test1;
retain temp_daima;
do group=1 to n; /*根据要求可知分成n组(nobs=n)*/
do i=1 to &y; /*每组有y个观测*/
p=group-1+i; /*计算指针位置*/
if group=n and i=&y then stop; /*使用指针时,要用stop*/
if p>n then continue; /*最后几组观测数小于y,这一行与上一行不能交换位置*/
set test nobs=n point=p; /*获得数据集test的观测数为n,指针指向第p个观测*/
if i=1 then temp_daima=daima;
else if daima^=temp_daima then continue;
output;
end;
end;
run;