Search code examples
sast-test

sas: when category variable has more than three levels, can I just select two levels data to run two sample t-test


As the title, I have a category variable including A,B,C three levels. I want to just select two levels such as A and B, as I know C is none of the business to run two sample t-test.

  proc ttest data=ABC plots(shownull)=interval;
          class var3 ###please add your code here###;
          var var23; 
          title ' two samples t-test A&B';
  run;

Solution

  • You can always filter your dataset to include only two levels.

    Where var3 ne 'C';
    

    Usually you would use an ANOVA instead when you have 3 levels and then you could do pairwise comparisons but you need to correct for multiple testing. PROC ANOVA incorporates options for this type of analysis.