BookmarkSubscribeRSS Feed
Sean_OConnor
Fluorite | Level 6

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. 

 

ID1ID2Final idSecond Id
xxxx5b5b-
6ixxxx6i-
8c5j8c5j
9gxxxx9g-
10b10b10b-

 

 

Any help would be great! 

4 REPLIES 4
Reeza
Super User

You have the 'xxx' in your dataset as indicated?

Sean_OConnor
Fluorite | Level 6

Hi Reeza,

Yes all failed matches have a 'xxxx' inserted.

Reeza
Super User

Look at the IFC function. 

 

Or in Query builder, created a new column. You can use a CASE statement in your computed column. 

Astounding
PROC Star

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 = '-';

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 794 views
  • 0 likes
  • 3 in conversation