Date: Thu, 21 Oct 2004 07:58:43 -0700
Reply-To: Dennis Diskin <diskin@SNET.NET>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Dennis Diskin <diskin@SNET.NET>
Subject: Re: Time sequence data processing
In-Reply-To: <200410211413.i9LED4Gc027008@listserv.cc.uga.edu>
Content-Type: text/plain; charset=us-ascii
Solomon,
Try:
Data a;
set test nobs=nobs;
do point = _N_+1 to nobs until (price lt next_price);
set test(rename=(price=next_price qt=next_qt)) point=point;
end;
if price ge next_price then
do; /* replace . with default value or use format to display DEFAULT for missing */
next_price = .;
next_qt = .;
end;
run;
HTH,
Dennis Diskin
Solomon Anchen <solo_in@REDIFFMAIL.COM> wrote:
Hi ,
Here is what i am trying . Below is the input dataset.
data test;
input qt time8. price;
datalines;
09:37:03 34.5
09:38:40 34.5
09:39:30 34.48
09:43:21 34.5
09:45:32 34.51
09:50:31 34.5
09:54:32 34.52
09:56:34 34.51
09:59:09 34.52
;
run;
for each observation i would like the subsequent higher price .Below is the
expected output.
expected results:
qt price nxt higher price nxt higher price time
09:37:03 34.5 34.51 09:45:32
09:38:40 34.5 34.51 09:45:32
09:39:30 34.48 34.5 09:43:21
09:43:21 34.5 34.51 09:45:32
09:45:32 34.51 34.52 09:54:32
09:50:31 34.5 34.52 09:54:32
09:54:32 34.52 default value default value
09:56:34 34.51 34.52 09:59:09
09:59:09 34.52 default value default value
This is just a sample , the actual input dataset has roughly 20 million
observations , so performance is paramount in a situation like this.
Thanks,
Solomon