LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (February 2003, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Tue, 25 Feb 2003 12:53:25 -0600
Reply-To:   Tomás Cámara <tchx0507@PMICIM.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Tomás Cámara <tchx0507@PMICIM.COM>
Subject:   Re: Question on merge with duplicate keys
In-Reply-To:   <9B1FC0A47040D411964F0002A5608C6CDDE760@HCCEXC02>
Content-type:   text/plain; charset=iso-8859-1

http://v8doc.sas.com/sashtml/

has pretty much everything you need in it.

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Femminella, Oliver Sent: Tuesday, February 25, 2003 12:39 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: Question on merge with duplicate keys

Thanks Tomas ! I really need to start using proc sql, can anybody point me in the right direction (docs, webpages, etc.) Oliver

-----Original Message----- From: Tomás Cámara [mailto:tchx0507@PMICIM.COM] Sent: 25 February 2003 18:32 To: SAS-L@LISTSERV.UGA.EDU Subject: Re: Question on merge with duplicate keys

Try mergin via an sql statement, since it contemplates all possible combinations (rather than looking for single entries in one of the sets)?

The following:

proc sql;create table sortie as

select a.id,fruit,color from one as a ,two as b

where a.id=b.id;quit;

does it.

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Femminella, Oliver Sent: Tuesday, February 25, 2003 12:19 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Question on merge with duplicate keys

Dear SAS-L,

I have a question when performing a merge of two datasets which have duplicate keys:

DATA one; INPUT id $ fruit $; CARDS; 1 N 1 Y 2 N 2 Y 3 N ; RUN;

PROC SORT data=one; BY id; RUN;

DATA two; INPUT id $ color $; CARDS; 1 100 2 50 2 20 3 80 ; RUN;

PROC SORT data=two; BY id; RUN;

DATA final; merge one two; BY id; RUN;

The result of the above merge is:

1 N 100 1 Y 100 2 N 50 2 Y 20 3 N 80

However the desired output from a merge between dataset 'one' and 'two' that I am looking for is the following:

1 N 100 1 Y 100 2 N 50 2 N 20 2 Y 50 2 Y 20 3 N 80

I would be grateful for any suggestions as to how I can obtain the above result.

Cheers, Oliver

-- Dr. Oliver Femminella Decision support systems Halifax Cetelem Credit Ltd. Leo House, Railway Approach, Wallington, Surrey SM6 0XD, U.K. T: +44 (0)20 8254 7234 M: +44 (0)7929 981 950 F: +44(0)20 8669 8857 E: oliver.femminella@halifaxcetelem.com

This electronic message contains information from Halifax Cetelem Credit Ltd which may be privileged or confidential. The information is intended to be for the use of the individual(s) or entity named above. If you are not the intended recipient be aware that any disclosure, copying, distribution or use of the contents of this information is prohibited. If you have received this electronic message in error, please notify us by telephone or email (to the numbers or address above) immediately. This electronic message contains information from Halifax Cetelem Credit Ltd which may be privileged or confidential. The information is intended to be for the use of the individual(s) or entity named above. If you are not the intended recipient be aware that any disclosure, copying, distribution or use of the contents of this information is prohibited. If you have received this electronic message in error, please notify us by telephone or email (to the numbers or address above) immediately.


Back to: Top of message | Previous page | Main SAS-L page