Hello
I want to calculate for each team category the following 4 measurements:
1-Number of customers
2-Row percent of (1)
3-Number of bad customers
4-Row percent of (3)
5-Bad Rate (which is calculated by (3)/(1)
There should be also a Total row.
My question is why in statistics (4) I don't see 100% in total row?
Data Rawtbl;
input ID team score;
cards;
1 a 7
2 a 8
3 a 6
4 a 6
5 b 11
6 b 11
7 b 8
8 c 9
9 c 11
10 c 7
;
run;
Data Rawtbl2;
Set Rawtbl;
Bad=(score=11);
noa=1;
Run;
proc tabulate data=Rawtbl2;
class team;
var bad noa;
table team='' ALL,
N='Number Customers'*f=comma8.
PCTN <team all>='Row PCT Number customers'
bad='Number bad customers'*SUM=''*f=comma8.
bad='Row percent of Number bad Customers'*PCTSUM=''
bad='Bad Rate'*PCTSUM <noa>=''/box='Team' rts=10;
Run;
First thing, the first data step has all missing values for Team because you have character values but don't read it as such.
When I fix the data step to read TEAM as character I do see 100 percent for the rowpct on the ALL.
So either your data is different or you need to describe a bit more what is not as expected. Such as Show the tabulate results. Probably the best way to do that is to turn on the ODS Listing desitnation, copy the results and past into a code. The results I got for your code, after the data step fix,
The SAS System 07:58 Thursday, April 23, 2020 1 „ƒƒƒƒƒƒƒƒ…ƒƒƒƒƒƒƒƒ…ƒƒƒƒƒƒƒƒƒƒƒƒ…ƒƒƒƒƒƒƒƒ…ƒƒƒƒƒƒƒƒƒƒƒƒ…ƒƒƒƒƒƒƒƒƒƒƒƒ† ‚Team ‚ ‚ ‚ Number ‚Row percent ‚ ‚ ‚ ‚ Number ‚ Row PCT ‚ bad ‚ of Number ‚ ‚ ‚ ‚Custome-‚ Number ‚custome-‚ bad ‚ ‚ ‚ ‚ rs ‚ customers ‚ rs ‚ Customers ‚ Bad Rate ‚ ‡ƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒ‰ ‚a ‚ 4‚ 40.00‚ 0‚ 0.00‚ 0.00‚ ‡ƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒ‰ ‚b ‚ 3‚ 30.00‚ 2‚ 66.67‚ 66.67‚ ‡ƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒ‰ ‚c ‚ 3‚ 30.00‚ 1‚ 33.33‚ 33.33‚ ‡ƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒ‰ ‚All ‚ 10‚ 100.00‚ 3‚ 100.00‚ 30.00‚ Šƒƒƒƒƒƒƒƒ‹ƒƒƒƒƒƒƒƒ‹ƒƒƒƒƒƒƒƒƒƒƒƒ‹ƒƒƒƒƒƒƒƒ‹ƒƒƒƒƒƒƒƒƒƒƒƒ‹ƒƒƒƒƒƒƒƒƒƒƒƒŒ
All the odd characters are because I use SAS Monospace font in my OUTPUT window and they don't make that font available on the forum. but the structure of the output should be fine.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.