BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Sathish_jammy
Lapis Lazuli | Level 10

Dear Experts,

 

I couldn't get the 100% in freq of the age column. Kindly go through the result below for more info.

Age_catFrequencyPercent
18-2512013.33
26-3518020
36-4518020
46-5518020
56-6512013.33
>6512013.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!

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

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.

View solution in original post

3 REPLIES 3
Kurt_Bremser
Super User

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.

Reeza
Super User

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!

 

 


 

ballardw
Super User

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.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
What is Bayesian Analysis?

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 1877 views
  • 4 likes
  • 4 in conversation