3 Replies Latest reply on Nov 16, 2016 3:29 PM by Shinichiro Murakami

    Choosing record closest to second date variable?

    lisa.kessler

      Hello:

       

      I have row level data as follows:

       

       

      IDCapacityDate
      141/1/2014
      152/1/2014
      2101/1/2014
      2131/15/2014
      2121/30/2014
      391/1/2014
      383/3/2014
      4151/1/2014
      4163/1/2014

       

      Where ID is the identifier for a unique homeless shelter and capacity is the number of people they can house. My goal is to do a time series over the three month span of 1/1/2014-3/31/2014 to see how capacity changes over time. For a separate date variable, I want to select the row which is the closest to that date variable. For example, if the date variable is for 2/1/2014, I want to select the second instance of ID 1, the third instance of ID 2, and the first instances of IDs 3 and 4.

       

      Any help would be greatly appreciated!