Hi all,
For my data, in Proc Report, I am trying to calculate row percentages in an across variable, for grouped data. I am using the following code and for all observations, it is generating right result except for one where only _c2 is 0. I am unable to figure out why it is happening that way.
Heading1 | 1 | 1 | 2 | 2 | 3 | 3 | ||||
count | % | count | % | count | % | count | % | mean | N | |
observation1 | 37 | 35.58% | 31 | 29.81% | 21 | 20.19% | 15 | 14.42% | 2.13 | 104 |
observation2 | 21 | 20.19% | 31 | 29.81% | 31 | 29.81% | 21 | 20.19% | 2.5 | 104 |
observation3 | 20 | 19.42% | 32 | 31.07% | 33 | 32.04% | 18 | 17.48% | 2.48 | 103 |
observation4 | 12 | 11.65% | 29 | 28.16% | 40 | 38.83% | 22 | 21.36% | 2.7 | 103 |
observation5 | 0 | 0 | 10 | 0 | 53 | 0 | 39 | 0 | 3.28 | 0 |
observation6 | 9 | 8.82% | 16 | 15.69% | 50 | 49.02% | 27 | 26.47% | 2.93 | 102 |
observation7 | 4 | 3.85% | 24 | 23.08% | 41 | 39.42% | 35 | 33.65% | 3.03 | 104 |
observation8 | 19 | 18.45% | 29 | 28.16% | 31 | 30.10% | 24 | 23.30% | 2.58 | 103 |
observation9 | 17 | 16.50% | 29 | 28.16% | 34 | 33.01% | 23 | 22.33% | 2.61 | 103 |
Could it be that you have in fact a missing value, and set OPTIONS MISSING to 0?
I reset the options missing=. and used sum() instead of +
I am getting correct results now.
Thanks for the help!
options missing=0;
does not change any values, it only changes how they are displayed. Therefore the simple addition will still result in missing values also, and that's why you need to use the SUM function.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.