Greeting community !!
I need to calculating the percentage with different denominator.
for variable A% - G%, the denominator is variable "All", so the computation is straight forwards.
But hwo should I calculate variable All%, which use the Total (sum of variable "All").
I hope I am clear. Can someone point me a direction.... Thanks !!!
All | A | B | C | D | E | F | G | All% | A% | B% | C% | D% | E% | F% | G% | |
Z | 356 | 69 | 36 | 19 | 69 | 15 | 59 | 89 | 356/1002 | 69/356 | 36/356 | 19/356 | 69/356 | 15/356 | 59/356 | 89/356 |
Y | 371 | 32 | 7 | 90 | 87 | 29 | 47 | 79 | 371/1002 | |||||||
X | 275 | 46 | 49 | 31 | 35 | 94 | 14 | 6 | 275/1002 | |||||||
Total | 1002 | ## | 15 | 83 | 33 | 96 | 60 | 93 |
Hi @zimcom
You can also simply use a proc freq. It depends whether you want to stick to the format of the output.
proc freq;
table y*x;
run;
One of the below two links might give you an idea:
https://support.sas.com/resources/papers/proceedings13/134-2013.pdf
data have;
input y $ x $;
datalines;
X A
X A
X B
Y A
Y B
Y B
Y B
;
proc tabulate data=have noseps;
class y x;
table
y all,
(all x) (all x)*colpctn
;
run;
Hi @zimcom
You can also simply use a proc freq. It depends whether you want to stick to the format of the output.
proc freq;
table y*x;
run;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.