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.
@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.
@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 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.