proc means data=y n; var id; run; proc sort data=y out=y1; by gender; run; data male female; set y1; if gender='m' then output male; else if gender='f' then output female; run; data x; set male; retain Mno; if first.gender='m' then Mno+1; if last.gender; run; data x1; set female; retain Fno; if first.gender='f' then Fno+1; if last.gender; run; data gp1 gp2 gp3; set x; Mcnt=Mno/31; g1=Mcnt*10; g2=Mcnt*11; do i=1 to Mno; if i<= g1 then output gp1; g4=g1+g1; else if g1 <i<= g4 then output gp2; g6=g4+g2; else if g4<i<= g6 then output gp3; end; run; data gp4 gp5 gp6; set x1; Fcnt=Fno/31; gf1=Fcnt1*10; gf2=fcnt*11; do i=1 to Fno; if i<= gf1 then output gp4; gf4=gf1+gf1; else if gf1 <i<= gf4 then output gp5; gf6=gf4+gf2; else if gf4<i<= gf6 then output gp6; end; run; then Append the datasets gp1 & gp4,gp2 & gp5 and gp3 & gp6
... View more