DATA Step, Macro, Functions and more

Retain Two IDs then

Reply
Regular Contributor
Posts: 194

Retain Two IDs then

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!

Super Contributor
Posts: 307

Re: Retain Two IDs then

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

Ask a Question
Discussion stats
  • 1 reply
  • 140 views
  • 0 likes
  • 2 in conversation