DATA Step, Macro, Functions and more

Big Crosstab for N in 5 categorical variables

Reply
Occasional Contributor
Posts: 6

Big Crosstab for N in 5 categorical variables

Hi all,

 

I'm struggling to make a certain type of table I've been asked for. In essence, I need a crosstab table of all of my categorical variables so I will know cell counts. So, for example, if I had race, sex, and eye color then I will need a table of Race*sex*eyecolor by race*sex*eyecolor. So if I needed to know how many white females have green eyes I will be able to have one cell that gives the N of that specific category. I can't for the life of me figure this out. The best advice I've had so far is to use a PROC FREQ procedure, but this generates many tables for each possibility, and I need one big table.

 

 

proc freq data=mn1;
tables iedtotal_50*iedpreed_50*iededs_50*school_2*bc_1*pb_method*wm_cog_admin/ nopercent nocol norow;
run;

Could anyone help me with this? I'm sure someone out there must know how to do this. Appreciate it.

Super User
Posts: 22,844

Re: Big Crosstab for N in 5 categorical variables

proc freq data=mn1;
tables iedtotal_50*iedpreed_50*iededs_50*school_2*bc_1*pb_method*wm_cog_admin/ out=want list nopercent nocol norow;
run;

 

Try that, the LIST to create a list table instead and an OUT to output a data set with the data instead of a report.

 


@TMSmith wrote:

Hi all,

 

I'm struggling to make a certain type of table I've been asked for. In essence, I need a crosstab table of all of my categorical variables so I will know cell counts. So, for example, if I had race, sex, and eye color then I will need a table of Race*sex*eyecolor by race*sex*eyecolor. So if I needed to know how many white females have green eyes I will be able to have one cell that gives the N of that specific category. I can't for the life of me figure this out. The best advice I've had so far is to use a PROC FREQ procedure, but this generates many tables for each possibility, and I need one big table.

 

 

proc freq data=mn1;
tables iedtotal_50*iedpreed_50*iededs_50*school_2*bc_1*pb_method*wm_cog_admin/ nopercent nocol norow;
run;

Could anyone help me with this? I'm sure someone out there must know how to do this. Appreciate it.



 

Ask a Question
Discussion stats
  • 1 reply
  • 57 views
  • 0 likes
  • 2 in conversation