Hi, I need to sort by Descending Counts for variable 'cALL' without ruining the sort order of aedecod nested in aebodsys. The current sort order is alphabetical by aebodsys and aedecode nested inside. Current Code: data pfinal1;
set tcombine (drop=_name_) ;
by ord1 aebodsys AEDECOD desc;
if ord1 in (1 2) then do;
array _value ctrtg1 ctrtg2 ctrtg3 ctrtg4 call ;
do over _value;
if _value = "" then _value="0 (0.0%)";
end;
end;
total1 = sum(input(scan(call, 1), best.));
if ord1 = 1 then ordx1 = 9999;
if ord1 = 2 then do;
retain ordx1;
if AEDECOD = "" then do;
* ordx1 = total1;
subordx1 = 9999;
end;
* else subordx1 = total1;
end;
**reassign sort order for table output;
if desc='Subjects with Any AEs, n (%)' then do; aebodsys='Subjects with Any AEs, n (%)'; aedecod='Subjects with Any AEs, n (%)'; ord1=1; end;
else if desc='Solicited Adverse Event' then do; aebodsys='Subjects with Any AEs, n (%)'; aedecod='Subjects with Any AEs, n (%)'; desc=' Solicited'; ord1=2; end;
else if desc='Unsolicited Adverse Event' then do; aebodsys='Subjects with Any AEs, n (%)'; aedecod='Subjects with Any AEs, n (%)';desc=' Unsolicited'; ord1=3; end;
else if desc='Lab Abnormality' then do; aebodsys='Subjects with Any AEs, n (%)'; aedecod='Subjects with Any AEs, n (%)';desc=' Lab Abnormalitites'; ord1=4; end;
else if aebodsys='UNCODED' then ord1=6;
else ord1=5;
rename ctrtg1=TRTG1 ctrtg2=TRTG2 ctrtg3=TRTG3 ctrtg4=TRTG4;
run;
proc sort data= pfinal1 out= final1 ;
by descending ordx1 ord1 aebodsys /*descending subordx1*/ descending total1 aedecod desc ;
run; in descending counts within SOC and PT . I attached the actual sas data. Current sort order of actual data:
... View more