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!
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;
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;
Remove the age2 variable from the TABLES statement:
proc freq data = have;
where age2 = 1;
tables overlap2 / chisq nocol nopercent;
run;
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!
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.