**Construct character variable parts;
if aval gt 0 then do;
if denom le 0 or count le 0 then numpart = '0';
else numpart = trim(left(put(count,8.)));
if denom le 0 or count le 0 then pctpart = '';
else pctpart = trim(left(put(round(count*100/denom, 0.1), pct1dp.)));
end;
run;
**Find space required for each part ;
proc sql noprint;
select max(max(lengthn(strip(numpart))),1),
max(max(lengthn(strip(pctpart))),1) into :numlength, :pctlength
from all_counts;
quit;
** Produce formatted results;
data npct;
length result $34;
set all_counts;
lengthr=length(numpart);
if lengthr = 1 then do;
result = right(put(numpart, 3.)) || ' ' || right(put(pctpart, &pctlength..));
end;
if lengthr = 2 then do;
result = right(put(numpart, 3.)) || ' ' || right(put(pctpart, &pctlength..));
end;
run;
This is how I'm constructing it and the lengthr coding is me trying to adjust for the issue
... View more