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.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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