|
Hi Susie,
That is really strange. It should update all all matching records. Try this one:
DATA Main;
x=1; y=1; OUTPUT;
x=1; y=2; OUTPUT;
x=2; y=1; OUTPUT;
x=2; y=2; OUTPUT;
RUN;
DATA Table;
x=1; z=1; OUTPUT;
x=2; z=2; OUTPUT;
x=3; z=3; OUTPUT;
RUN;
DATA Updated;
MERGE Main (IN=InMain) Table; BY x;
IF InMain;
RUN;
PROC PRINT DATA=Updated; RUN;
If you would have used UPDATE instead of MERGE it would yield the result that you indicate.
Regards - Jim.
--
. . . . . . . . . . . . . . . .
Jim Groeneveld, MSc.
Biostatistician
Science Team
Vitatron B.V.
Meander 1051
6825 MJ Arnhem
Tel: +31/0 26 376 7365
Fax: +31/0 26 376 7305
Jim.Groeneveld@Vitatron.com
www.vitatron.com
My computer has the solutions, I have the problems.
[common disclaimer]
-----Original Message-----
From: Susie Li [mailto:Susie.Li@US.SANOFI.COM]
Sent: Tuesday, November 18, 2003 22:33
To: SAS-L@LISTSERV.UGA.EDU
Subject: How to do table lookup in SAS when main dataset has multiple
records with the same key
Suppose I have my MAIN dataset (with fields: employee_id table_id), and the
lookup table in TABLE dataset (with fields: table_id value), and I want to
read the value from TABLE into MAIN for every employee:
Data MAIN;
merge MAIN (in=a) TABLE;
by table_id;
if a;
Above will update ONLY one record of the MAIN employees with the value of
the table_id.
Is there any other way to update all employees in MAIN with the same
table_id with its corresponding value in TABLE?
Important: The Information in this e-mail belongs to Sanofi-Synthelabo Inc.,
is intended for the use of the individual or entity to which it is addressed,
and may contain information that is privileged, confidential, or exempt from
disclosure under applicable law. If you are not the intended recipient, you
are hereby notified that any disclosure, copying, distribution, or use of, or
reliance on, the contents of this e-mail is prohibited. If you have received
this e-mail in error, please notify us immediately by replying back to the
sending e-mail address, and delete this e-mail message from your computer.
|