02-07-2018 01:36 PM - edited 02-07-2018 01:40 PM
proc report; column pct_x; define pct_x / computed width=6 ' % of X'; compute pct_x / length = 5; pct_x = (num_x/denom_x)*100; endcomp; run;
Whenever I try to assign format statement in either define row or compute row I get 0% as result instead of the actual value.
WIth this code I am getting the right percentages but they do not seem to be formatted (eg 27.53, 4.567). I want to keep only two digits after the decimal point and insert a % sign as well if possible (eg 27.53%, 4.56%)
Thank you for your help.
02-07-2018 01:40 PM
We can't run your code if you don't provide sample data.
And it's really bad practice to not have a DATA= in your PROCS.
proc report data=have nowd;
02-07-2018 01:54 PM
Percent formats are tricky in two respects.
First, they expect to see decimal fractions. So don't multiply by 100.
Second, they need a wider width than you would imagine. Percent formats insert a blank before and after. So printing 100.00% requires a total of 9 characters.