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.png

 

Secure your spot at the must-attend AI and analytics event of 2024: SAS Innovate 2024! Get ready for a jam-packed agenda featuring workshops, super demos, breakout sessions, roundtables, inspiring keynotes and incredible networking events.

 

Register by March 1 to snag the Early Bird rate of just $695! Don't miss out on this exclusive offer. 

 

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.

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