A quick way is to capture the PROC FREQ output, filter it using a WHERE and then display the results using PROC PRINT.
@greg6363 wrote:
I created a frequency table in the following form:
No (0) Yes (1) Total
Group A. 16 27 43
Group B. 25. 67 92
Group C. 37 91 128
Since I only wanted to see the Yes (1) column in the output,
I used a where statement in proc freq to remove the no (1) column.
However, this is how I want the final table to look:
Yes(1) Total
Group A. 41 %
Group B. 62 %
Group C. 88 %
In PROC FREQ, both columns produce the exact same values.
I want the output to show the percentage of the total dataset including the column that is not included in the output. So what I need to do is create a variable for a new column with the following calculation: Pct = Yes(1) / Total (for each group)
I couldn’t get it to work in PROC FREQ but is there a way to do it in PROC REPORT or PROC TABULATE?
Any assistance would be greatly appreciated. Thanks
.
For a 0/1 variable, the % of 1's will be the mean of the variable. Just use (guessing at your variable names here):
proc means data=have mean;
var flagvar;
class group;
run;
@greg6363 wrote:
However, this is how I want the final table to look:
Yes(1) Total
Group A. 41 %
Group B. 62 %
Group C. 88 %
This is what I'm referring to. If this has changed, post what you want the new output table to look like.
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.