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.



 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

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