Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I update a SAS field with a field from another Table?

Status
Not open for further replies.

mbliss

Programmer
Aug 28, 2002
3
US
How can I update a field in one table with data from another table. (In access, an "update" query)
I have tried to join the tables and then update the field that I need, but I keep getting errors!!!!!!!!
 
mbliss,
If the updating field is also residing in a separate SAS DATASET then you would merge two dataset, dropping the original value and retaining new one.
/**dataset to be updated
drop the original field1 sort by the merge field here it is "key"**/
proc sort data=dsn.data1 out=data1(drop=field1);
by key;
run;

/***dataset that has new values that would be used to do update**/
proc sort data=dsn.data2 out=data2(keep=key field1);
by key;
run;

data new;
merge
data1(in=in1)
data2(in=in2)
; by key;
if in1 and in2;/**this is an inner join**/
run;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top