Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Nearest value in a not xtset-able panel dataset

From   Francesco <>
Subject   st: Nearest value in a not xtset-able panel dataset
Date   Wed, 28 Mar 2012 19:12:15 +0200

Dear Statalist,

I have a simple algorithmic problem that I was unable to solve so far...
Let us assume that I have the following dataset, where special_date
identifies ... a special date ;-)

Jack   1               0                           missing
Jack   4               0                            -1
Jack   4               0                            -1
Jack   5               1                            0
Jack   7               0                            missing
Jack   9               0                            missing
Jack   10             0                            missing
Jack   11             0                            -1
Jack   12             1                            0
Jack   13             0                            +1
Jack   13             0                            +1
Jack   17             0                            missing

My question is :

How could I obtain the variable DIFFERENCE that gives me the
difference between the current observation's date and the nearest
special date if this distance is less than a threshold N (N=1 in the
In any case N is much smaller than the periodicity of special date.
For example N could be 10 days and Special date could occur only one
time each quarter.

Could you please help me (if possible)?

Many, many thanks in advance,


*   For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index