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

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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