Dear Experts,
I couldn't get the 100% in freq of the age column. Kindly go through the result below for more info.
Age_cat | Frequency | Percent |
18-25 | 120 | 13.33 |
26-35 | 180 | 20 |
36-45 | 180 | 20 |
46-55 | 180 | 20 |
56-65 | 120 | 13.33 |
>65 | 120 | 13.33 |
If I sum up the percentage it returns 99.99. There is no missing/ value 0 in the age column. How could I solve it, Please suggest some ideas?
Thanks in advance!
It may help to share data and the actual code used. Normally Proc Freq will show two decimals for every percentage.
Example:
proc freq data=sashelp.class; tables age; run;
yields
Cumulative Cumulative Age Frequency Percent Frequency Percent ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ 11 2 10.53 2 10.53 12 5 26.32 7 36.84 13 3 15.79 10 52.63 14 4 21.05 14 73.68 15 4 21.05 18 94.74 16 1 5.26 19 100.00
So, since you are not showing any decimals for the 20 percent values you have done something other than default. That might be the cause. With a data set that would replicate your behavior:
data junk; input cat freq; datalines; 1 120 2 180 3 180 4 180 5 120 6 120 ; run; proc freq data=junk; tables cat/ nocum out=work.summary; weight freq; run;
we get
cat Frequency Percent ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ 1 120 13.33 2 180 20.00 3 180 20.00 4 180 20.00 5 120 13.33 6 120 13.33
and if you examine the created output set work.summary you will find there are more decimal places as each of your categories with 120 frequency will have repeating decimals of .33333333 etc.
So summing those will approach 100.
Or a different procedure:
proc tabulate data=junk; class cat; freq freq; tables cat All='Total', n pctn; run;
But where or however you "sum" the percentage column manually you need to actually know the actual values involved.
That's the math of limited digits. Add one decimal digit for the display (percent8.3), then your manual addition will result in 99.999, and when you round that to 0.01, you get 100.
Add another decimal place to the output. It’s due to rounding into thirds which doesn’t work evenly ever.
@Sathish_jammy wrote:
Dear Experts,
I couldn't get the 100% in freq of the age column. Kindly go through the result below for more info.
Age_cat Frequency Percent 18-25 120 13.33 26-35 180 20 36-45 180 20 46-55 180 20 56-65 120 13.33 >65 120 13.33 If I sum up the percentage it returns 99.99. There is no missing/ value 0 in the age column. How could I solve it, Please suggest some ideas?
Thanks in advance!
It may help to share data and the actual code used. Normally Proc Freq will show two decimals for every percentage.
Example:
proc freq data=sashelp.class; tables age; run;
yields
Cumulative Cumulative Age Frequency Percent Frequency Percent ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ 11 2 10.53 2 10.53 12 5 26.32 7 36.84 13 3 15.79 10 52.63 14 4 21.05 14 73.68 15 4 21.05 18 94.74 16 1 5.26 19 100.00
So, since you are not showing any decimals for the 20 percent values you have done something other than default. That might be the cause. With a data set that would replicate your behavior:
data junk; input cat freq; datalines; 1 120 2 180 3 180 4 180 5 120 6 120 ; run; proc freq data=junk; tables cat/ nocum out=work.summary; weight freq; run;
we get
cat Frequency Percent ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ 1 120 13.33 2 180 20.00 3 180 20.00 4 180 20.00 5 120 13.33 6 120 13.33
and if you examine the created output set work.summary you will find there are more decimal places as each of your categories with 120 frequency will have repeating decimals of .33333333 etc.
So summing those will approach 100.
Or a different procedure:
proc tabulate data=junk; class cat; freq freq; tables cat All='Total', n pctn; run;
But where or however you "sum" the percentage column manually you need to actually know the actual values involved.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.