proc freq data=EMDATA.VIEW_AYL noprint; format REASON $7. ; table REASON /out=EMPROJ.FRQ2E5HG (rename=(count=_npop_ percent=_pctpop_)) missing; run; quit; proc sort data=EMPROJ.FRQ2E5HG out=EMPROJ.FRQ2E5HG; by descending _npop_; run; data EMDATA.SMPMPIYN(label="Sample of EMDATA.VIEW_AYL."); set EMDATA.VIEW_AYL; drop _n000001 _s000001 _n000002 _s000002 _n000003 _s000003 ; length _SFormat1 $200; drop _SFormat1; _SFormat1 = trim(left(put(REASON,$7.))); if _SFormat1 = 'DebtCon' then do; _n000001 + 1; if _s000001 < 393 then do; if ranuni(12345)*(3928 - _n000001) <=(393 - _s000001) then do; _s000001 + 1; output; end; end; end; else if _SFormat1 = 'HomeImp' then do; _n000002 + 1; if _s000002 < 178 then do; if ranuni(12345)*(1780 - _n000002) <=(178 - _s000002) then do; _s000002 + 1; output; end; end; end; else if _SFormat1 = '' then do; _n000003 + 1; if _s000003 < 25 then do; if ranuni(12345)*(252 - _n000003) <=(25 - _s000003) then do; _s000003 + 1; output; end; end; end; run;