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

Hi all:

 

I have a dataset around 16K obs.   I would like to create a table with count for variable Place with difference Race.  For example, the Place include CA, GA, NY, etc.  The Race include White, Asian, African American, etc.   I would like to know the different race counts in CA, etc.   Please advice how to approach them, maybe Proe Freq Group?  Also, I would like to including the missing number.   Thanks.

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

@ybz12003 wrote:

Hi all:

 

I have a dataset around 16K obs.   I would like to create a table with count for variable Place with difference Race.  For example, the Place include CA, GA, NY, etc.  The Race include White, Asian, African American, etc.   I would like to know the different race counts in CA, etc.   Please advice how to approach them, maybe Proe Freq Group?  Also, I would like to including the missing number.   Thanks.

 


And what do you mean by "include missing number"? Do mean you want a "count" of 0 for a race that does not occur in a specific place?

Do you want data set or a report?

One way for a report that people read might be

data example;
   input place race;
datalines;
1 1
1 2
1 3
1 2
1 3
1 2
1 3
1 4
2 1
2 2
2 1
2 2
2 4
. 1
;
run;

proc tabulate data=example;
  class place race /missing;
  table place,
        race*n=''
        /misstext='0'
   ;
run;

I didn't bother to fake character values for place as I'm feeling lazy. The Tabulate part doesn't really care if a class variable is numeric or character the main difference is how missing values would display.

 

Also if you have FORMATS for the place and race an option of PRELOADFMT would help if a specific expected value never actually appears in the data.

View solution in original post

2 REPLIES 2
Reeza
Super User
Sounds like a standard PROC FREQ. Did that not work for some reason?
ballardw
Super User

@ybz12003 wrote:

Hi all:

 

I have a dataset around 16K obs.   I would like to create a table with count for variable Place with difference Race.  For example, the Place include CA, GA, NY, etc.  The Race include White, Asian, African American, etc.   I would like to know the different race counts in CA, etc.   Please advice how to approach them, maybe Proe Freq Group?  Also, I would like to including the missing number.   Thanks.

 


And what do you mean by "include missing number"? Do mean you want a "count" of 0 for a race that does not occur in a specific place?

Do you want data set or a report?

One way for a report that people read might be

data example;
   input place race;
datalines;
1 1
1 2
1 3
1 2
1 3
1 2
1 3
1 4
2 1
2 2
2 1
2 2
2 4
. 1
;
run;

proc tabulate data=example;
  class place race /missing;
  table place,
        race*n=''
        /misstext='0'
   ;
run;

I didn't bother to fake character values for place as I'm feeling lazy. The Tabulate part doesn't really care if a class variable is numeric or character the main difference is how missing values would display.

 

Also if you have FORMATS for the place and race an option of PRELOADFMT would help if a specific expected value never actually appears in the data.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 2 replies
  • 2372 views
  • 0 likes
  • 3 in conversation