Programming the statistical procedures from SAS

Omit observation for proc ttest

Reply
Occasional Contributor
Posts: 14

Omit observation for proc ttest

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.

Respected Advisor
Posts: 3,124

Re: Omit observation for proc ttest

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 ;

Occasional Contributor
Posts: 14

Re: Omit observation for proc ttest

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

Ask a Question
Discussion stats
  • 2 replies
  • 177 views
  • 0 likes
  • 2 in conversation