SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
mimosa09
Calcite | Level 5

Hello,

I am doing some work on a dataset looking at infectious disease outcomes and their relationship to socioeconomic variables. I have a continuous "number of people in the household outcome" that I am trying to turn into a dichotomous variable (greater than 5 and less than or equal to 5). The variable currently ranges from 2-16. How can I go about coding this?

Thanks so much for your help!

1 REPLY 1
ChrisHemedinger
Community Manager

If I understand you, you want a dummy variable that is true (or 1) if the household is > 5, else it should be 0 (or false). 

 

This is one simple way to calculate this. Note it doesn't take into account what should happen if the continuous variable has a missing value.

data want;
 set have;
 length is_household_gt_5 8;
 /* assuming household_size is continuous */
 is_household_gt_5 = (houshold_size > 5);
run;
 

 

Register for SAS Innovate 2025!! The premier event for SAS users, May 6-9 in Orlando FL. Sign up now for the best deals!

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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