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

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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