10-21-2017 11:06 AM - edited 10-21-2017 11:07 AM
Hi I come across a task that requires the final output of the data to be one big summary table (all the rows are categorical variables, want to see the distribution break down; and the columns reflect different population group, I want to see the count), it looks like:
If there is a missing variable, report missing as well.
|Patients who got vaccine||Patients who didn't get vaccine|
The input data looks like:
The methods I know, proc report, proc mean, etc, only give me summary statistics for one category at a time, and I am not interested in how different categories intersects with each other, don't need something like Race*Age. The real data I work with have way more different population categories like the two big columns, but the rows that need to be reported are the same across population groups.
I am wondering if there is any way to systematically 'stack' summary statistics of each row category, so that I won't need to stack them by hand for my real data (10 row categories, 20 column population categories).
Any suggestion is greatly appreciated.
10-21-2017 12:28 PM
Try using PROC TABULATE.
If you have difficulties with it - please:
1) post your data in a input datalines format
2) post the code you tried (and log if needed) to point where is your issue.
10-21-2017 12:30 PM
PROC REPORT will do this.
Better yet is to do the calculations in PROC SUMMARY and then have PROC REPORT make the final report in the format you want.
10-21-2017 12:33 PM
I have a macro that does some of this. You can find it here. You'll likely need to customize your output further to get exactly what you need.
10-23-2017 10:49 AM
Please describe your problem in terms of your variables. Your output has two column headings but it is not clear what role the variable followup_flag may play, or which "%" you want: row, column or table.
If you want the two levels of Vaccine_flag to generate the output, with 1=got vaccine and 2= didn't then something like this may be a start:
proc format library=work; format vacc 1="Patients who got vaccine" 0="Patients who didn't get vaccine" ; run; proc tabulate data=have; class gender race ethnicity age; class vaccine_flag /descending; format vaccine_flag vacc.; table gender race ethnicity age, vaccine_flag=''*(n='Number' RowPctN='%') /misstext=' '; run;
10-23-2017 01:46 PM