Folks,
I have three numeric variables which range from 0 to n and I would like to compare if they match across records and if not which way to they disagree.
The name my variables are A , B and C. I've drawn the logic out in a 3 way Venn Diagram but I'm trying to write a if clause in SAS to extract out the information. I have 7 combinations in total.
A
B
C
A=B
A=C
B=C
A=B=C
I would like to have something written such as; if A=B=C then Cohort='ABC'
if A=B then Cohort='AB' and so on.
Any help on this would be great.
In fact, you have only 5 "combinations":
So my code would look like
data want;
set have;
if a = b and b = c then result = "all match";
else if a = b then result = "A=B";
else if a = c then result = "A=C";
else if b = c then result = "B=C";
else result = "no match";
run;
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.