Use SAS proc expand for filling missing values
<p>I have the following problem:</p>

<p>I want to fill missing values with proc expand be simply taking the value from the next data row.</p>

<p>My data looks like this:</p>

<pre><code>date;index;
29.Jun09;-1693
30.Jun09;-1692
01.Jul09;-1691
02.Jul09;-1690
03.Jul09;-1689
04.Jul09;.
05.Jul09;.
06.Jul09;-1688
07.Jul09;-1687
08.Jul09;-1686
09.Jul09;-1685
10.Jul09;-1684
11.Jul09;.
12.Jul09;.
13.Jul09;-1683
</code></pre>

<p>As you can see for some dates the index is missing. I want to achieve the following:</p>

<pre><code>date;index;
29.Jun09;-1693
30.Jun09;-1692
01.Jul09;-1691
02.Jul09;-1690
03.Jul09;-1689
04.Jul09;-1688
05.Jul09;-1688
06.Jul09;-1688
07.Jul09;-1687
08.Jul09;-1686
09.Jul09;-1685
10.Jul09;-1684
11.Jul09;-1683
12.Jul09;-1683
13.Jul09;-1683
</code></pre>

<p>As you can see the values for the missing data where taken from the next row (11.Jul09 and 12Jul09 got the value from 13Jul09)</p>

<p>So proc expand seems to be the right approach and i started using this code:</p>

<pre><code>PROC EXPAND DATA=DUMMY
OUT=WORK.DUMMY_TS
FROM = DAY
ALIGN = BEGINNING
METHOD = STEP
OBSERVED = (BEGINNING, BEGINNING);

ID date;
CONVERT index /;
RUN;
QUIT;
</code></pre>

<p>This filled the gaps but from the previous row and whatever I set for ALIGN, OBSERVED or even sorting the data descending I do not achieve the behavior I want. </p>

<p>If you know how to make it right it would be great if you could give me a hint. Good papers on proc expand are apprechiated as well.</p>

<p>Thanks for your help and kind regards
Stephan</p>