BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
awardell
Obsidian | Level 7

Hi! 

 

From my research I think proc freq or proc tabulate may be used to create a table that I would like to make: 

 

I have three variables, Ethnicity (Hispanic, non-hispanic), Race (White, AA, Asian, Pacific Islander, ...) and Gender (Male, Female, Unspecified) 

 

I would like to make a table that looks like the following: 

       Racial Categories                                                                       Ethnicity 

                                                     Hispanic                                     Nonhispanic                                  Not Reported                    TOTAL    

                                        Female Male not-reported         Female Male not-reported              Female Male not-reported

White 

African American 

Asian                                                                        FREQUENCY COUNTS 

Pacific Islander 

etc

 

What would be the best way to create a table like this in SAS? I am fairly new to SAS, so a thorough explanation would be greatly appreciated.I believe I have SAS version 9.4

.

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

@awardell wrote:

Thanks for your speedy response. I have put this in SAS, and this gives me the gender by ethnicity table. I'm guessing I will need to do something similar to this to get the tables with all three variables: 

 

proc tabulate data=gender_p;
class race ethnicity gender;
table race, ethnicity*gender
run;

 

Thanks so much!!!


It depends on how you want to look at things.

One thing it may be helpful to know is that Proc Tabulate supports multiple table statements.

Second is the , separates dimensions (page, row and column) and * nests variables and statistics within a dimension:

so you might look at

proc tabulate data=gender_p;
class race ethnicity gender;
table race, 
      ethnicity*gender 
;
table race, 
      ethnicity,
      gender
;
table race * ethnicity,
      gender
;
table race * ethnicity *  gender
;
table race ethnicity gender,
      race ethnicity gender
;



run;

for a variety. The N statistic is assumed for class variables is no other is requested. There are a number of percentages that could be requested as well.

View solution in original post

3 REPLIES 3
Reeza
Super User
Look into PROC TABULATE.
Something as simple as the following should get you started:

proc tabulate data=have;
class ethnicity gender;
table ethnicity, gender;
run;
awardell
Obsidian | Level 7

Thanks for your speedy response. I have put this in SAS, and this gives me the gender by ethnicity table. I'm guessing I will need to do something similar to this to get the tables with all three variables: 

 

proc tabulate data=gender_p;
class race ethnicity gender;
table race, ethnicity*gender
run;

 

Thanks so much!!!

ballardw
Super User

@awardell wrote:

Thanks for your speedy response. I have put this in SAS, and this gives me the gender by ethnicity table. I'm guessing I will need to do something similar to this to get the tables with all three variables: 

 

proc tabulate data=gender_p;
class race ethnicity gender;
table race, ethnicity*gender
run;

 

Thanks so much!!!


It depends on how you want to look at things.

One thing it may be helpful to know is that Proc Tabulate supports multiple table statements.

Second is the , separates dimensions (page, row and column) and * nests variables and statistics within a dimension:

so you might look at

proc tabulate data=gender_p;
class race ethnicity gender;
table race, 
      ethnicity*gender 
;
table race, 
      ethnicity,
      gender
;
table race * ethnicity,
      gender
;
table race * ethnicity *  gender
;
table race ethnicity gender,
      race ethnicity gender
;



run;

for a variety. The N statistic is assumed for class variables is no other is requested. There are a number of percentages that could be requested as well.

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1631 views
  • 1 like
  • 3 in conversation