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

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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