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;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
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.