Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

# Re: st: filling in the gaps

 From Jan Ditzen To statalist@hsphsun2.harvard.edu Subject Re: st: filling in the gaps Date Fri, 18 Jan 2013 10:00:41 +0100

Sorry, I was not aware of the missing years. Instead of only adding a one, calculate the difference between the years and add it to the grade the school year before:
```
```
```
Best wishes,
Jan

Am 18.01.2013 09:44, schrieb Jan Ditzen:
```
```Good morning,
if I understood your problem correctly the following should help:

```
"by id (sch_year), sort:" makes sure that the data gets sorted in the correct way, i.e. by individuals (id) and then by school year. Secondly the by command makes sure that the command behind the colon is repeated for each group. If grade is missing (if grade == .) then the value is replaced by the preceding value (grade[_n-1]) added with one. I think the only problem which might occur is if pupils repeat a year.
```
Maybe there is a better solution but I think this should work.

All the best,

Jan
Am 18.01.2013 09:21, schrieb John Singhammer:
```
```Dear statalister

```
I'm working on a dataset consisting of information on 45.000 school children
```Data has been collected annually since 2009, though not for all children

Information on grade has been imported from a national register.
However, that information is only available up to the year 2011

Consequently, information on grade is missing for the year 2012 and 2013

The data look like this:

347246    2010    2
347246    2011    3
347246    2012    .
731909    2010    4
731909    2011    5
731909    2012    .
901302    2011    4
901302    2013    .

How do I fill in the blanks?... and how do I take care of the cases
where information is missing for an entire year (eg. id 901302)?

Note: A school year is calculated as beginning in august  and ending
in june the next year. Thus, the year 2011 begins august 2010 and ends
in june 2011.

Any advices would be much appreciated.

Thanks.
John Singhammer
University of Southern Denmark
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/

```
```
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/

```
```

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/
```