BookmarkSubscribeRSS Feed
JUMMY
Obsidian | Level 7

I have a variable listed as follows:

 

Smoker: 1=never, 2=former, 3=current

 

How do I perform a two-sample t-test on a variable XX to examine the differences in former and current smokers (excluding those who never smoked from the analysis) in sas? I used the following code:

 

Data have;

set want;

 

proc sort;

by smoker;

run;

 

run;

proc ttest data=have alpha=0.05;

var XX;

class smoker;

run;

 

How do I make exclusions from the variable smoker?

 

 

1 REPLY 1
mcgaugh
Fluorite | Level 6

The quickest and easiest way to do that is add a where statement to your proc ttest if you want to keep all three levels in your "want" dataset.

 

proc ttest data=have alpha=0.05;

var XX;

class smoker;

where smoker in (2,3);

run;

https://twitter.com/epi_chic/status/983120587236225025

https://twitter.com/epi_chic/status/983120587236225025

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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