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 (May 2007, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Wed, 2 May 2007 09:46:09 -0500
Reply-To:   "Huang, JS" <Huang.JS@PRINCIPAL.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   "Huang, JS" <Huang.JS@PRINCIPAL.COM>
Subject:   Re: Merging question
Comments:   To: andre_couturier@HOTMAIL.COM
In-Reply-To:   A<1178116210.184495.138140@c35g2000hsg.googlegroups.com>
Content-Type:   text/plain; charset="us-ascii"

Andre:

I just sent an implementation to the list. I don't think the statement "by I;" is needed. If you omit this statement and encounter error, please send back your log window.

JS

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of andre_couturier@HOTMAIL.COM Sent: Wednesday, May 02, 2007 9:30 AM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: Merging question

On May 2, 10:19 am, andre_coutur...@hotmail.com wrote: > On May 2, 7:43 am, Huang...@PRINCIPAL.COM ("Huang, JS") wrote: > > > > > > > See if this is what you are looking for. I assume you only want to > > combine the same id from data1 and data2. If not, modify or write > > back for more questions. > > > data data1; > > input id start end; > > datalines; > > 1 -381 196 > > 1 100 100 > > 1 -381 196 > > 1 52 97 > > ; > > > data data2; > > input id all; > > datalines; > > 1 -381 > > 1 52 > > 1 97 > > 1 100 > > 1 196 > > ; > > > data data3; > > set data1; > > do i=1 to ObsCount; > > set data2(rename=(id=id2)) point=i nobs=ObsCount; > > if id eq id2 then output; > > end; > > drop id2; > > run; > > > proc print data=data3; > > run; > > > ***** Output ***** > > The SAS System 06:19 > > Wednesday, May 2, 2007 15 > > > Obs id start end all > > > 1 1 -381 196 -381 > > 2 1 -381 196 52 > > 3 1 -381 196 97 > > 4 1 -381 196 100 > > 5 1 -381 196 196 > > 6 1 100 100 -381 > > 7 1 100 100 52 > > 8 1 100 100 97 > > 9 1 100 100 100 > > 10 1 100 100 196 > > 11 1 -381 196 -381 > > 12 1 -381 196 52 > > 13 1 -381 196 97 > > 14 1 -381 196 100 > > 15 1 -381 196 196 > > 16 1 52 97 -381 > > 17 1 52 97 52 > > 18 1 52 97 97 > > 19 1 52 97 100 > > 20 1 52 97 196 > > > -----Original Message----- > > From: SAS(r) Discussion [mailto:S...@LISTSERV.UGA.EDU] On Behalf Of > > > andre_coutur...@HOTMAIL.COM > > Sent: Tuesday, May 01, 2007 7:41 PM > > To: S...@LISTSERV.UGA.EDU > > Subject: Merging question > > > Hi SAS-L-ers, > > > I have the following 2 datasets. > > I would like to merge them and get the results as shown in the 3rd one. > > > data1 looks like this > > > id start end > > 1 -381 196 > > 1 100 100 > > 1 -381 196 > > 1 52 97 > > > data2 looks like this > > > id all > > 1 -381 > > 1 52 > > 1 97 > > 1 100 > > 1 196 > > > I would like to get data 3 to look like this > > > id start end all > > 1 -381 196 -381 > > 1 -381 196 52 > > 1 -381 196 97 > > 1 -381 196 100 > > 1 -381 196 196 > > 1 100 100 -381 > > 1 100 100 52 > > 1 100 100 97 > > 1 100 100 100 > > 1 100 100 196 > > 1 -381 196 -381 > > 1 -381 196 52 > > 1 -381 196 97 > > 1 -381 196 100 > > 1 -381 196 196 > > 1 52 97 -381 > > 1 52 97 52 > > 1 52 97 97 > > 1 52 97 100 > > 1 52 97 196 > > > Could someone provide a datastep solution. > > > Thanks! > > > -----Message Disclaimer----- > > > This e-mail message is intended only for the use of the individual > > or entity to which it is addressed, and may contain information that

> > is privileged, confidential and exempt from disclosure under applicable law. > > If you are not the intended recipient, any dissemination, > > distribution or copying of this communication is strictly > > prohibited. If you have received this communication in error, please

> > notify us immediately by reply email to Conn...@principal.com and > > delete or destroy all copies of the original message and attachments

> > thereto. Email sent to or from the Principal Financial Group or any > > of its member companies may be retained as required by law or regulation. > > > Nothing in this message is intended to constitute an Electronic > > signature for purposes of the Uniform Electronic Transactions Act > > (UETA) or the Electronic Signatures in Global and National Commerce > > Act ("E-Sign") unless a specific statement to the contrary is included in this message. > > > While this communication may be used to promote or market a > > transaction or an idea that is discussed in the publication, it is > > intended to provide general information about the subject matter > > covered and is provided with the understanding that The Principal is

> > not rendering legal, accounting, or tax advice. It is not a marketed

> > opinion and may not be used to avoid penalties under the Internal > > Revenue Code. You should consult with appropriate counsel or other > > advisors on all matters pertaining to legal, tax, or accounting > > obligations and requirements.- Hide quoted text - > > > - Show quoted text - > > This is Great, Thanks! > > What if I have more than 1 Id in data 1 and data 2 Say > > data data1; > input id start end; > datalines; > 1 -381 196 > 1 100 100 > 1 -381 196 > 1 52 97 > 2 -576 172 > 2 68 78 > 2 -576 78 > ; > > data data2; > input id all; > datalines; > 1 -381 > 1 52 > 1 97 > 1 100 > 1 196 > 2 -576 > 2 68 > 2 78 > 2 172 > ; > > and I would like to get > > id start end all > 1 -381 196 -381 > 1 -381 196 52 > 1 -381 196 97 > 1 -381 196 100 > 1 -381 196 196 > 1 100 100 -381 > 1 100 100 52 > 1 100 100 97 > 1 100 100 100 > 1 100 100 196 > 1 -381 196 -381 > 1 -381 196 52 > 1 -381 196 97 > 1 -381 196 100 > 1 -381 196 196 > 1 52 97 -381 > 1 52 97 52 > 1 52 97 97 > 1 52 97 100 > 1 52 97 196 > 2 -576 172 -576 > 2 -576 172 68 > 2 -576 172 78 > 2 -576 172 172 > 2 68 78 -576 > 2 68 78 68 > 2 68 78 78 > 2 68 78 172 > 2 -576 78 -576 > 2 -576 78 68 > 2 -576 78 78 > 2 -576 78 172 > > I tried updating your code by adding by id; after the set data1 and > set data2 but got > ERROR: The POINT= option is incompatible with the BY statement. > > Could you tell me how to modify the code. > > Thanks! > Andre- Hide quoted text - > > - Show quoted text -

Huang:

I think I found it. Please correct if I'm wrong.

Only need 1 by id statement .

data data3; set data1; by id; %*** HERE; do i=1 to ObsCount; set data2(rename=(id=id2)) point=i nobs=ObsCount; if id eq id2 then output; end; drop id2; run;

Thanks! Andre

-----Message Disclaimer-----

This e-mail message is intended only for the use of the individual or entity to which it is addressed, and may contain information that is privileged, confidential and exempt from disclosure under applicable law. If you are not the intended recipient, any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by reply email to Connect@principal.com and delete or destroy all copies of the original message and attachments thereto. Email sent to or from the Principal Financial Group or any of its member companies may be retained as required by law or regulation.

Nothing in this message is intended to constitute an Electronic signature for purposes of the Uniform Electronic Transactions Act (UETA) or the Electronic Signatures in Global and National Commerce Act ("E-Sign") unless a specific statement to the contrary is included in this message.

While this communication may be used to promote or market a transaction or an idea that is discussed in the publication, it is intended to provide general information about the subject matter covered and is provided with the understanding that The Principal is not rendering legal, accounting, or tax advice. It is not a marketed opinion and may not be used to avoid penalties under the Internal Revenue Code. You should consult with appropriate counsel or other advisors on all matters pertaining to legal, tax, or accounting obligations and requirements.


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