Bookmark and Share

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


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

Re: st: filling in the gaps


From   Jan Ditzen <[email protected]>
To   [email protected]
Subject   Re: st: filling in the gaps
Date   Fri, 18 Jan 2013 09:44:09 +0100

Good morning,
if I understood your problem correctly the following should help:

by id (sch_year), sort: replace grade = grade[_n-1]+1 if grade == .

"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:

id	sch_year	grade
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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index