As in the attachment, I have multiple "pair_" variables.
I used the following code to get freqency on the categories of each "pair_:" variable
proc freq data=have;
table Pair_:;
run;
In the "Results Viewer" I got many freq tables of each "Pair_:" variable.
For example, "pair_1_2" looks like following
Pair_1_2 | Frequency | Percent | Cumulative Frequency |
Cumulative Percent |
---|---|---|---|---|
different resp and both wrong | 35 | 17.50 | 35 | 17.50 |
different resp and one of them | 37 | 18.50 | 72 | 36.00 |
same resp and both correct | 118 | 59.00 | 190 | 95.00 |
same resp and both wrong | 10 | 5.00 | 200 | 100.00 |
Now I want to stack all of the freq table into One table, then using the stacked freq table, I want to divided "frequency" by 149, and get a "new_pct" variable, the results I wanted will look like the following:
category | freq | pct_new | ||
different resp and both wrong | 35 | 149 | 0.23 | |
different resp and one of them | 37 | 149 | 0.25 | |
pair_1_2 | same resp and both correct | 118 | 149 | 0.79 |
same resp and both wrong | 10 | 149 | 0.07 | |
different resp and both wrong | 42 | 149 | 0.28 | |
pari_1_3 | different resp and one of them | 34 | 149 | 0.23 |
same resp and both correct | 114 | 149 | 0.77 | |
same resp and both wrong | 10 | 149 | 0.07 |
What's the efficient SAS code to stack all freq tables and then get the final wanted table ? Any help would be much appreciated!
Actually...disregard the previous message, you need this one, since you're only looking at one variable at a time. For some reason I thought you were looking at two. This is an example of exactly what you want.
Actually...disregard the previous message, you need this one, since you're only looking at one variable at a time. For some reason I thought you were looking at two. This is an example of exactly what you want.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.