Date: Wed, 28 Jul 2004 13:39:59 -0400
Reply-To: Sigurd Hermansen <HERMANS1@WESTAT.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Sigurd Hermansen <HERMANS1@WESTAT.COM>
Subject: Re: update dataset
Content-Type: text/plain
Hiren:
This example illustrates a very general way to update a table (dataset)
using data linked to another table (dataset) by key values:
data server1;
input
MODE: $char8. SERVER: $char8. Z: $char3. Log: $char6.
;
cards;
TESTMODE SERVER2V O1Z Log229
FULLMODE SERVER2V O1Z Log190
;
run;
data server2;
input
MODE: $char8. SERVER: $char8. Z: $char3. Log: $char6.
;
cards;
TESTMODE SERVER2V O1Z Log230
;
run;
proc sql;
update server1 as t1
set Log=(select t2.Log from server2 as t2
where t2.MODE=t1.MODE and t2.SERVER=t1.SERVER and t2.Z=t1.Z
)
where exists(select * from server2 as t2
where t2.MODE=t1.MODE and t2.SERVER=t1.SERVER and
t2.Z=t1.Z
)
;
quit;
Sig
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Hiren
Sent: Wednesday, July 28, 2004 10:51 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: update dataset
I want to change a value in an existing dataset. I have only come across
examples where the update is done via another dataset. Any ideas...?
e.g.
dataset observation:
TESTMODE SERVER2 O1Z Log229 (change this value to Log230)
Thanks
Hiren