BookmarkSubscribeRSS Feed
jcis7
Pyrite | Level 9

G'day:

Appreciate any  help you can give.  How do you merge the two fields and retain both IDs.

Then, match based on a chosen ID between two files.

This question is Not Answered.

jcis7Newbie

Currently Being Moderated                   

Hello!  Any help you can give is appreciated!

I've DataFile1:

ID                  Type       Address             (other fields, etc...)

12345678      B             1 Aurora Ln                            

12345676      A             1 Aurora Ln                              

12345677      A             30 Chester Way                 

12345667      B             30 Chester Way                  

12345654      A             45 Picadilly Ln

12345432      B             45 Picadilly Ln           

How do you merge with the following

RESULT 1

IDA                    IDB                      Address                  (other fields, etc)

12345676         12345678             1 Aurora Lane

12345677         12345667             30 Chester Way

12345654         12345432             45 Picadilly Ln

I've another data file, Data File 2,  that has the ID listed for the Type B's from DataFile1 but for which I need to replace the ID listed from DataFile1 with the Type A ID.  The address for DataFile 2 may not be the same as the address for data file 1.

Data File 2 also has other IDs that are correct and therefore don't need updating.

Data File 2

ID                  Type       Address             (other fields, etc...)

---observations with the same ID listed in DataFile1 but may have updated information

12345678      B             1 Aurora Ln  #B                                                                     

12345667      B             305 Chester Wy                  

12345432      B             45 Picadilly Ln 

.....more observations that don't need the ID number changed

13456787      A             300 Westinghouse

14556764      B             134 Hemingway

How do you match RESULT 1 with Datafile 2 (i.e., match IDB from RESULT 1 to ID in DataFile 2) but then keep only IDA and he Updated Address from DataFile 2 to get the Final Table below

Need:  Final Table

ID                  Type       Address             (other fields, etc...)                       

12345676      A             1 Aurora Ln #B                               

12345677      A             305 Chester Way                               

12345654      A             45 Picadilly Ln

13456787      A             300 Westinghouse

14556764      B             134 Hemingway

Thank you!

1 REPLY 1
Fugue
Quartz | Level 8

Isn't this the same as https://communities.sas.com/thread/48311??

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

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
  • 1 reply
  • 636 views
  • 0 likes
  • 2 in conversation