| Date: | Tue, 7 Dec 2004 14:59:48 -0500 |
| Reply-To: | Ya Huang <ya.huang@AMYLIN.COM> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | Ya Huang <ya.huang@AMYLIN.COM> |
| Subject: | Re: Simple data querying problem |
|
A less efficient but maybe easy to understand data step solution:
DATA A;
input time;
cards;
9.00
13.00
14.00
21.00
DATA B;
input time;
cards;
9.25
13.50
23.00
;
data expb (drop=time rename=(expandt=time));
set b;
do expandt=time-1 to time+1 by 0.05;
expandt=round(expandt,.01);
output;
end;
run;
proc sort;
by time;
run;
data akeep;
merge a (in=a) expb (in=b);
by time;
if a and b;
run;
proc print;
run;
The idea is to expand each record of B to cover the time span
of -1 to +1 hour of it, assume the time accuracy is 0.05 hour.
then merge the expanded B with A and test where the record
is from.
Kind regards,
Ya Huang
On Tue, 7 Dec 2004 13:43:34 -0500, Zach Peery <zpeery@NATURE.BERKELEY.EDU>
wrote:
>Hi All,
>
>Sorry about the last post - it seemed to want to send itself. in the
>meanwhile - I thought of a better way to explain the problem...
>
>I am trying to identify observations in dataset A that occured within 1
>hour of any observation in dataset B, and place these observations in a
>new dataset. Note that time is in hh.hh format such that 13.50 = 1:30 pm.
>
>DATASET A
>time
>9.00
>13.00
>14.00
>21.00
>
>DATASET B
>time
>9.25
>13.50
>23.00
>
>DESIRED DATASET
>time1
>9.00
>13.00
>14.00
>
>Thanks, I really appreciate any help that the list can provide. Zach
|