|Date: ||Mon, 20 Apr 1998 16:22:26 -0700|
|Reply-To: ||"William W. Viergever" <wwvierg@IBM.NET>|
|Sender: ||"SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>|
|From: ||"William W. Viergever" <wwvierg@IBM.NET>|
|Subject: ||Re: Help: How to compare observations?|
|Content-Type: ||text/plain; charset="us-ascii"|
At first glance this did seem bizarre, but if, instead of focusing on the first OBS and how to find the corresponding one later on (i.e., the first one 300 seconds later), you should focus on for OBS, looking backwards (using LAG functions and RETAINs) until you find one that was 300 seconds earlier.
From the looks of you price data, there appears to be enough LAGs available in SAS (i.e., the relevant question is: does SAS nest LAGS 10 deep?, 15 deep?, etc.).
It should come together quite nicely from this view point.
Hope this helps.
At 11:00 PM 4/16/98 -0500, Robin Chou wrote:
>I have been working on this problem for some time but can't figure out
>how to program it in SAS. I would be grateful if you can help me out.
>I have a data set of stock prices which looks like:
>Name Price Time
>IBM 13.0 34200
>IBM 13.2 34300
>IBM 13.4 34550
>IBM 12.9 34650
>IBM 12.5 34800
>IBM 12.8 34860
>IBM 13.0 34960
>IBM 13.2 35350
>IBM 13.5 35400
>. . .
>. . .
>. . .
>Where the time is cumulative seconds from midnight.
>Now, I need to calculate the price difference between a observation and
>the first following observation that is at least 300 seconds after it.
>For example, I want to calculate the price difference between the first
>observation and the fourth observation because the fourth observation is
>the first following observation that is at least 300 seconds after the
>first one. Similarly, the second observation is also compared to the
>fourth observation and the price difference between them is calculated,
>because the fourth observation is also the first one that is at least
>300 seconds away from the second one. Same comparison and calculation
>are done for every observation in the data set.
>Any suggestions will be greatly appreciated. Thank you for your
W. W. Viergever
Viergever & Associates