proc sql;
create table ex1 as
select * from
(select 'group1' as group,add,group1 as num from ex
union all
select 'group2' as group,add,group2 as num from ex)
order by ranuni(0);
quit;
data ex2(drop=s1 s2);
set ex1;
retain s1 1 s2 1;
if s1<=1000 and group="group1" then do;
s1+1;
id="1";
end;
else if s2<=22550 then do;
s2+1;
id= "2";
end;
else do;
id="3";
end;
run;
/*id为分组情况*/