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: Loop over time


From   Richard Goldstein <[email protected]>
To   [email protected]
Subject   Re: st: Loop over time
Date   Thu, 11 Mar 2010 11:10:48 -0500

I see no reason for a loop here; ensure that the data are sorted by id
and then time (sort id time) and then

replace sex=sex[_n-1] if sex=="" & id==id[_n-1]

then do the same for race

Rich

Dmitriy Krichevskiy wrote:
> Hello Statalisters,
> I have a small problem which I seem to be unable to solve. I have a
> large panel dataset. But the creators of the data did not carry
> variables such as race and gender beyond the first entry of an
> individual in the dataset. I am attempting to fix this issue via
> creating a simple loop but get an error message that time series
> operators are not allowed (even though I have declared the dataset
> xtset, and even tried tsset). Below I provide an examples of the data,
> all help is much appreciated, as always. Dmitriy
> 
> id   time sex race ....
> 1     2     M    W
> 1     3      .      .
> 2     1     F     H
> 3     1     F     B
> 3     2     .      .
> 3     3     .      .
> 
> 
> Research Associate, College of Education
> Lumina Foundation Project
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


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