Folks,
I wonder could I get some help on the following. I have two existing character variables which are both ids. One is a product of method a while the other is a product of method b.
I would like to create a third variable which takes the accurate matches from both. A simple table illustrates my point.
Also where we have a contrasting match this output is placed in a second variable.
| ID1 | ID2 | Final id | Second Id |
| xxxx | 5b | 5b | - |
| 6i | xxxx | 6i | - |
| 8c | 5j | 8c | 5j |
| 9g | xxxx | 9g | - |
| 10b | 10b | 10b | - |
Any help would be great!
You have the 'xxx' in your dataset as indicated?
Hi Reeza,
Yes all failed matches have a 'xxxx' inserted.
Look at the IFC function.
Or in Query builder, created a new column. You can use a CASE statement in your computed column.
It sounds like some simple logic would do.
if ID1=ID2 then Final_id = ID1;
else if ID1='xxxx' then Final_id = ID2;
else if ID2 = 'xxxx' then Final_id = ID1;
else do;
Final_id = ID1;
Second_id = ID2;
end;
Optionally, if you really want to, you could add:
if Second_id = ' ' then Second_id = '-';
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.