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

Hello,

 

I have a data set where I know certain values are incorrect and need changing.  I can't change them from my extraction program (as they are locked).  I know, I know, but this is what I have to work with.  The issue is that there are multiple fields that need to be corrected.  If I put all the fields in the merge/overwrite doc, it changes the old values to blank.  Is there a way to only take the values specified in the overwrite data set and not all of it?  An example of my overwrite data set is below.  The "Parent" data set has the below fields and more.

 

PR IDReportability IndicatorComplaint Code (s)Clinical Harm(s)Product FamilyModel NumberHospital Country:
1001     Italy
4556     United Kingdom
4557      
4584      
4585     Germany
4611      
9212Yes     
11001Yes     
11028Yes     
12014Yes     
12289   ABCD  
18315Yes     
19008Yes     
19149     France
19328Yes     
19649   XYZ  
19800Yes     
20229    PN-12345 


Thanks,

 

Wes

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

@PGStats wrote:

Use the update statement. Default behavior doesn't overwrite missing values. To update dataset have with values from dataset overwrite do :

 

data updated;
update have overwrite;
by PR_ID;
run;

Which will require Have and Overwrite to both be sorted by PR_ID and the Have data set to have only one record with a given value of PR_ID.

 

If you have multiple records with the same value of PR_ID you would need a second (and possibly more variables) to uniquely identify the record to update and sort both sets by the combination of variables and use that on the BY statement.

 

If multiple records with the same PR_ID require the same updated values you may want to look into Proc SQL join on PR_ID and Coalesce or Coalescec for the variables involved.

View solution in original post

2 REPLIES 2
PGStats
Opal | Level 21

Use the update statement. Default behavior doesn't overwrite missing values. To update dataset have with values from dataset overwrite do :

 

data updated;
update have overwrite;
by PR_ID;
run;
PG
ballardw
Super User

@PGStats wrote:

Use the update statement. Default behavior doesn't overwrite missing values. To update dataset have with values from dataset overwrite do :

 

data updated;
update have overwrite;
by PR_ID;
run;

Which will require Have and Overwrite to both be sorted by PR_ID and the Have data set to have only one record with a given value of PR_ID.

 

If you have multiple records with the same value of PR_ID you would need a second (and possibly more variables) to uniquely identify the record to update and sort both sets by the combination of variables and use that on the BY statement.

 

If multiple records with the same PR_ID require the same updated values you may want to look into Proc SQL join on PR_ID and Coalesce or Coalescec for the variables involved.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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