BookmarkSubscribeRSS Feed
TMSmith
Calcite | Level 5

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.

1 REPLY 1
Reeza
Super User
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.



 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 1 reply
  • 988 views
  • 0 likes
  • 2 in conversation