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;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 878 views
  • 3 likes
  • 3 in conversation