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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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