BookmarkSubscribeRSS Feed
toneill
Calcite | Level 5

Basic question for a new user:

I have a class variable (Y) that has >2 levels (yes/no/don't know/refused). I would like to perform a 2-sample t-test to compare population means on a survey at baseline (Z = 1). However, I know that my class variable will return an error of too many levels. How do I exclude "don't know" and "refused" observations (thus, only leaving those participants who responded "yes" or "no" responses)?

title X ;

proc ttest data = X ;

     class Y ;

     var A ;

          where Z = 1 ;

run ;

Thank you.

2 REPLIES 2
Haikuo
Onyx | Level 15

Something like this? Pay attention to the case for 'yes' , 'no'

title X ;

proc ttest data = X (where=(Y in ('yes', 'no')) ;

  class Y ;

  var A ;

  where Z = 1 ;

run ;

toneill
Calcite | Level 5

Thank you Hai.kuo

Just one minor correction on the parentheses:

title X ;

proc ttest data = X (where=(Y in ('yes','no'))) ;

     class Y ;

     var A ;

          where Z = 1 ;

run ;

Works perfectly! Thanks for helping me learn another SAS trick! Smiley Happy

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!

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
  • 2 replies
  • 1582 views
  • 0 likes
  • 2 in conversation