BookmarkSubscribeRSS Feed
ssulli11
Calcite | Level 5

I am trying to perform a chi-square test on a categorical variable with more that two responses.

 

For example Variable Age has three responses:

0: 18-29

1: 30-39

2: 40-49

 

I just want to perform the Chi-square for only the 30-39 age group between my two cohorts. I am sure there is a simple code for this, but I as of yet have been unable to find it.

 

Thank you for all your help!

 

3 REPLIES 3
PGStats
Opal | Level 21

You can restrict testing to a subset of your data with a WHERE statement. Example:

 

proc freq data=myData;

where age = 1;

.... some test ...

run;

PG
ssulli11
Calcite | Level 5

Thank you for your response!

 

Yes, this is how I originally thought to complete this as well.  However, the results are only giving me the table, not the chi-quare results with this code.

 

proc freq data = have;
where age2 = 1;
tables overlap2*age2 / chisq nocol nopercent;
run;

Rick_SAS
SAS Super FREQ

Remove the age2 variable from the TABLES statement:

 

proc freq data = have;
where age2 = 1;
tables overlap2 / chisq nocol nopercent;
run;

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 1083 views
  • 3 likes
  • 3 in conversation