Date: Thu, 13 Jul 2000 01:19:33 GMT
Reply-To: Theo DP <theodp@AOL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Theo DP <theodp@AOL.COM>
Organization: AOL http://www.aol.com
Subject: Re: merging problem
>Subject: merging problem
>From: raypere@NETSCAPE.NET (Ray Pere)
>Date: 7/12/00 7:44 PM Central Daylight Time
>Message-id: <20000713004417.29222.qmail@www0r.netaddress.usa.net>
>
>Dear Sas users: I have two data sets which are setup as shown below. I am
>trying to merge the data by id and date. The problem is that the dates need
>not be the same. Merging the data is fine as long as the ids are similar and
>the dates can differ between two days in absolute terms. Any form advice is
>most welcome. Thanks in advance.
>
>Ray
>
>Data 1
>Id x1 x2 x3
>a 2 3 10/12/99
>b 3 4 9/25/98
>c 4 7 7/20/97
>
>Data 2
>Id z1 z2 x3
>a 4 5 10/12/99
>c 6 7 9/25/98
>d 4 8 7/20/97
>
Get 'em into SAS data sets and use SQL...
No SAS currently at my disposal for a reality check, but something like:
PROC SQL;
SELECT DATA1.*, DATA2.z1, DATA2.z2 FROM DATA1, DATA2 WHERE DATA1.ID=DATA2.ID
and DATA1.ID BETWEEN DATA2.ID-2 AND DATA2.ID+2;
|