Help using Base SAS procedures

Update fields in one table based on another table.

Reply
Occasional Contributor
Posts: 5

Update fields in one table based on another table.

I have 2 SAS tables, HRIS and FAKC.  Both tables have a unique ID of NBKID.  The HRIS table has 276,438 records, and the FAKC table has 415 records.

I need a SAS procedure to update records in the HRIS table, based on fields in the FAKC table.

Specifically, when the NBKID’s match, I need to update the HRIS table field LobName, with the FAKC table field value FakcLobName, and the field AltLob with the value “FAKC”.

Actually I need to update other fields as well, but if you can help me with this, I can probably figure the rest out

I'm new to SAS and just learning, so please be specific in you reply.

Thanks in advance for your help

Super User
Posts: 19,771

Re: Update fields in one table based on another table.

Posted in reply to jhrbanker

Assuming all fields need to be updated and that if a record isn't found in HRIS table it needs to be added use the UPDATE statement.

SAS(R) 9.2 Language Reference: Dictionary, Fourth Edition

Step-by-Step Programming with Base SAS(R) Software

https://kb.iu.edu/d/aljg

Occasional Contributor
Posts: 5

Re: Update fields in one table based on another table.

All fields do not need to be updated (HRIS has 151 fields & FAKC has 26 fields).  The only fields that need to be updated are AltLob & LobName.

The HRIS LobName field needs to be updated with the value of the FAKC LobName field.  And the AltLob field needs to be populated with "FAKC".

All of the records in the FAKC table have a matching record in the HRIS table.  But not visa versa.

Please provide the required code or an example of how to use the Update statement.  I'm new to SAS and just learning.

Thanks,

John

Super User
Posts: 11,343

Re: Update fields in one table based on another table.

Posted in reply to jhrbanker

Is the NBKID field duplicated in the HRIS data set?

Occasional Contributor
Posts: 5

Re: Update fields in one table based on another table.

Yes.  The NBKID field is the key field in both tables.

Super User
Posts: 19,771

Re: Update fields in one table based on another table.

Posted in reply to jhrbanker

The links above have code and detailed comments. If you only have certain fields that need updating only keep those in your dataset use the keep = on the update statement.

update master transaction(keep=nbkid field1_update field2_update);

by nbkid;

Ask a Question
Discussion stats
  • 5 replies
  • 671 views
  • 0 likes
  • 3 in conversation