BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
mcmaxwell
Fluorite | Level 6

Hello,

I would like to run a Chi squared test on some data I collected. Here is an example of my dataset: 

mcmaxwell_0-1615307201568.png

c_ses3 has two levels (cPLTL or non-cPLTL) and refers to whether a student participated in a teaching intervention or not. ABC has two levels (ABC or DFW) and refers to a students final grade. Tutoring refers to how many tutoring sessions a student attended and ranges from 0 to 12. ST_c has 6 levels (0-1, 1-2, 2-3, 3-4, 4-5, 6+) and represents how much time a student spent studying weekly.

I used the code below to do the chi squared test:

/** get contingency table and run chisq**/     
proc freq data=all;    
	title "cPLTL 2-3h ST vs. non-cPLTL 3-4h ST";    
	table c_ses3 * ABC / chisq expected nopercent nocol norow;     
	where tutoring between 0 and 3;    
	run;    

As you can see, I am comparing the ABC rates of cPLTL and non-cPLTL groups, and I am only using students who attended 0, 1, 2, or 3 tutoring sessions. 

Here is my problem: I would like to specifically compare cPLTL students who studied 2-3 hours with non-cPLTL students who studied 3-4 hours. I am not sure how to write the code to subset the ST_c variable because the way it should be subsetted depends on the c_ses3 variable. Is there a way to do this? Or a different way I could organize my data? 

Thank you in advance!!!

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Sounds like you could do that with just a different WHERE clause.

where (c_ses3='cPLTL' and tutoring between 2 and 3)
   or (c_ses3='non-cPLTL' and tutoring between 3 and 4)
;

View solution in original post

1 REPLY 1
Tom
Super User Tom
Super User

Sounds like you could do that with just a different WHERE clause.

where (c_ses3='cPLTL' and tutoring between 2 and 3)
   or (c_ses3='non-cPLTL' and tutoring between 3 and 4)
;

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 345 views
  • 0 likes
  • 2 in conversation