I'm tryng to make a table that looks like this:
Education | Sex | |||||
Frequency Col Pct | FEMALE | MALE | Total | |||
N | % | N | % | N | % | |
No formal schooling | 0 | 0 | 4 | 2.31 | 4 | 155 |
Grade 8 or less | 0 | 0 | 9 | 5.2 | 9 | 3.49 |
Some high school | 5 | 5.88 | 31 | 17.92 | 36 | 13.95 |
High school graduate | 12 | 14.12 | 43 | 24.86 | 55 | 21.32 |
Some trade school/technical, college or university | 17 | 20 | 31 | 17.92 | 48 | 18.6 |
Trade school/technical training program graduate | 6 | 7.06 | 24 | 13.87 | 30 | 11.63 |
Community college graduate | 24 | 28.24 | 18 | 10.4 | 42 | 16.28 |
University Graduate | 21 | 24.71 | 13 | 7.51 | 34 | 13.18 |
Total | 85 | 100% | 173 | 100 | 258 | 100 |
But I can't seem to actually get it to look like this. I've been able to get the data I need by using this code:
proc freq data=demo_combined_final; tables program*ca_education*gender/norow; format ca_education education.; label gender='Gender' ca_education='Education' program='Program'; run;
But it's time consuming to have to reformat everything.
Does anyone know if it's possible to make a table like the above?
the female and male headings should go across the "N" and the "%" headings in the first 4 columns
You don't show how program fits but this may get you started with a different report procedure:
proc tabulate data=demo_combined_final; class ca_education gender; tables ca_education All='Total', (gender All='Total') *(n colpctn) ; format ca_education education.; label gender='Gender' ca_education='Education' program='Program'; run;
Procs Report and Tabulate come into play when you need more than Freq provides. They will also do statistics such as Proc means such as max, min, mean, standard deviation and others.
You don't show how program fits but this may get you started with a different report procedure:
proc tabulate data=demo_combined_final; class ca_education gender; tables ca_education All='Total', (gender All='Total') *(n colpctn) ; format ca_education education.; label gender='Gender' ca_education='Education' program='Program'; run;
Procs Report and Tabulate come into play when you need more than Freq provides. They will also do statistics such as Proc means such as max, min, mean, standard deviation and others.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.