Calcite | Level 5

## Incorrect Row percent in Proc Report

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.

proc report data= mydata;
classval,(n pct) ("Mean Rating" varval) ("N" all);
define label / group " ";
define classval / across order=formatted "Rating" format=rating. ;
define n /  "count" ;
define pct / computed  "%"  format=percent9.2;
define varval / mean " " format=8.2;
define all / computed " "  format=8.;
compute pct;
_c3_ = _c2_ /(_c2_ + _c4_ + _c6_ + _c8_ );
_c5_ = _c4_ /(_c2_ + _c4_ + _c6_ + _c8_ );
_c7_ = _c6_ /(_c2_ + _c4_ + _c6_ + _c8_ );
_c9_ = _c8_ /(_c2_ + _c4_ + _c6_ + _c8_ );
endcomp;
compute all;
all = _c2_ + _c4_ + _c6_ + _c8_ ;
endcomp;
run;

Output :
 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
3 REPLIES 3
Super User

## Re: Incorrect Row percent in Proc Report

Could it be that you have in fact a missing value, and set OPTIONS MISSING to 0?

Calcite | Level 5

## Re: Incorrect Row percent in Proc Report

I reset the options missing=. and used sum() instead of +
I am getting correct results now.

Thanks for the help!

Super User

## Re: Incorrect Row percent in Proc Report

``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.

Discussion stats
• 3 replies
• 149 views
• 0 likes
• 2 in conversation