BookmarkSubscribeRSS Feed
jhrbanker
Calcite | Level 5

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

5 REPLIES 5
Reeza
Super User

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

jhrbanker
Calcite | Level 5

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

ballardw
Super User

Is the NBKID field duplicated in the HRIS data set?

jhrbanker
Calcite | Level 5

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

Reeza
Super User

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;

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 5 replies
  • 1988 views
  • 0 likes
  • 3 in conversation