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 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

Discussion stats
  • 2 replies
  • 1987 views
  • 0 likes
  • 3 in conversation