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 1996, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 23 May 1996 18:46:10 -0400
Reply-To:     Pierre Beland <pbeland@RIQ.QC.CA>
Sender:       "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From:         Pierre Beland <pbeland@RIQ.QC.CA>
Subject:      Re: Multiple observation merge

Lucy Liu wrote: >I need some help for multiple observation merge. I have two huge data >sets. Data set1 has around 50000 observatons. Data set2 has around 1700 >observations. Both data sets have multiple observations. Here is the >data set1 and set2. > >data set1; >input id item gram; >cards; >1 1 2.2 >1 2 2.3 >1 3 3.3 >1 4 2.5 >2 1 1.4 >2 2 2.4 >2 3 3.1 >3 2 1.6 >3 3 1.2 >; >run; > >data set2; >input item prop code; >cards; >1 0.2 123 >1 0.3 212 >1 0.1 223 >1 0.5 231 >2 0.3 321 >2 0.3 331 >2 0.4 352 >3 0.5 421 >3 0.5 422 >4 0.4 323 >4 0.6 332 >; >run; > >Final data set should be like this: > >Id item gram prop code >1 1 2.2 0.2 123 >1 1 2.2 0.3 212 >1 1 2.2 0.1 223 >1 1 2.2 0.5 231 >1 2 2.3 0.3 321 >1 2 2.3 0.3 331 >1 2 2.3 0.4 352 >. >. >. >. >. > >I use following program to take care this problem. Anyway, it takes long >time to finish. Is there any best way to handle it. > >data new; >set one; >do obsnum=1 to last by 1; >set two (rename=(item=item1)) point=obsnum nobs=last; >if item=itme1 then output; >end; >run; > > >Any suggestion? Thanks in advanced. > > >Lucy Liu >Cancer research Center >University of Hawaii > >email:Lucyl@hawaii.edu >phone:(808)586-2995 > >

The following procedures will permit this merge:

1. proc sort by item;

data merge data1 data2; by item;

I use SAS 6.10 for Windows. It contains an Online sample library that can be accessed via the help menu. This library covers many subjects and is very useful to learn SAS. The programs can be copied and submitted for execution.

The book SAS LANGUAGE AND PROCEDURES is also a very good book to learn the basics of SAS. Examples presented in the book are also included in the Online Sample library.

Pierre Beland


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