proc freq data=EMDATA.VIEW_P8X; format BAD BEST12. ; table BAD /out=EMPROJ._FRQVP00(drop=percent); run; proc sort data=EMPROJ._FRQVP00; by descending count; run; data EMPROJ._FRQ9TPH(keep=count); set EMPROJ._FRQVP00; where (.01 * 50 * count) >= 3; run; %let seed = 12345; data EMDATA.TRNYHN3L EMDATA.VALCSH62 ; drop _c00: _partseed ; set EMDATA.VIEW_P8X; length _Pformat1 $200; drop _Pformat1; _Pformat1 = trim(left(put(BAD,BEST12.))); if _Pformat1 = '0' then do; _partseed = ranuni(12345); if (4771+1-_c000003)*_partseed <= (2386 - _c000001) then do; _c000001 + 1; output EMDATA.TRNYHN3L; end; else do; _c000002 + 1; output EMDATA.VALCSH62; end; _c000003+1; end; else if _Pformat1 = '1' then do; _partseed = ranuni(12345); if (1189+1-_c000006)*_partseed <= (595 - _c000004) then do; _c000004 + 1; output EMDATA.TRNYHN3L; end; else do; _c000005 + 1; output EMDATA.VALCSH62; end; _c000006+1; end; run;