BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
aigiss
Obsidian | Level 7

Hello everyone this is what I am dealing with. 

aigiss_0-1675370790769.png

I have three variables Syphilis Gonorrhea chlamydia (dichotomous) in dataset called "combined_dataset." I want to combined those variables to create a new variable "STIs" based on premise of 'N' and 'Y'. However, when I input the code (see below), the numbers are not adding up for the variable 'STIs' for 'Y' observations (should be n=1193). Can someone help? 

data combined_dataset;
  set combined_dataset;
  length STIs $1;
  if Syphilis = "Y" or Gonorrhea = "Y" or Chlamydia = "Y" then STIs = "Y";
  else combined_variable = "N";
run;

 

aigiss_1-1675370977915.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
A person can have more than one disease at a time, so the most that Y should be is 1,193 but not what it should be. If you have more than one disease, you get counted only once in this summary.

View solution in original post

5 REPLIES 5
Reeza
Super User
It should not be 1193 because it's not a mutually exclusive criteria. If they don't have chlamydia it doesn't mean they don't have something else at all.
aigiss
Obsidian | Level 7

I fail to understand your explanation, I apologize can you clarify your answer? 

Reeza
Super User
A person can have more than one disease at a time, so the most that Y should be is 1,193 but not what it should be. If you have more than one disease, you get counted only once in this summary.
aigiss
Obsidian | Level 7

Ooooh. That is right. Duh! Thank you for the explanation. I need my cup of coffee. 

Reeza
Super User
No worries, I initially mixed up the Y/N in my explanation.

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
  • 5 replies
  • 1536 views
  • 5 likes
  • 2 in conversation