BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
greg6363
Obsidian | Level 7

Is it possible to update a selection of variables within a dataset as opposed to every variable contained in a table?  In my case, I have a dataset with blank fields for several variables which I want to fill with current values from a table.  Here is my current code:

 

data accounts;
update set1 Master;
by accountnumber;
run;

 

I am creating a new dataset (accounts) that updates values from another data source (Master) for particular variables in my current dataset (set1) by the accountnumber field.  Is it possible to declare particular fields in my set1 dataset for the update statement?  When I run my code, it brings in EVERY field that is in the Master dataset.  I just want to update particular fields.  Any assistance would be greatly appreciated.  Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

The easiest approach would be to use a dataset option Keep list for the transaction data set (contains update values) if you only want some of those to update the master data set (the one receiving the updates). (Your name is counterintuitive but that is how SAS sees it).

 

data accounts;
update set1 Master(keep=accountnumber firstvartouse othervartouse);
by accountnumber;
run;

View solution in original post

2 REPLIES 2
ballardw
Super User

The easiest approach would be to use a dataset option Keep list for the transaction data set (contains update values) if you only want some of those to update the master data set (the one receiving the updates). (Your name is counterintuitive but that is how SAS sees it).

 

data accounts;
update set1 Master(keep=accountnumber firstvartouse othervartouse);
by accountnumber;
run;

greg6363
Obsidian | Level 7

It works.  You're right.  I'll change the name of that dataset to avoid confusion.  Thanks so much.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 2 replies
  • 428 views
  • 0 likes
  • 2 in conversation