Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

Re: st: change variable values in panel data


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: change variable values in panel data
Date   Sun, 17 Jun 2012 01:35:15 +0100

This is an FAQ.

FAQ     . . . . . . . . . . . . . . . . . . . . . . . Replacing missing values
        . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  N. J. Cox
        2/03    How can I replace missing values with previous or
                following nonmissing values?
                http://www.stata.com/support/faqs/data/missing.html

On Sat, Jun 16, 2012 at 11:36 PM, xueliansharon <xuelianstata@gmail.com> wrote:

> I have a panel data set in hand. Each individual enters the survey in
> different years. For each year, if the individual is a new interviewee, then
> he/she is asked about occupation in this wave; if he/she is a reinterviewee,
> then he/she won'e be asked about occupation, and thus occupation will take a
> missing values. The data structure is as follows:
>
> ID      year    Reinterviewee   occupation
> 1       1998    no                          3
> 1       1999    yes                         .
> 1       2000    yes                         .
> 2       1998    no                          5
> 2       1999    yes                         .
> 2       2000    yes                         .
> 3       1999    no                          4
> 3       2000    yes                         .
>
> Now I want to realize the following purpose: for each individual, if he is a
> reinterviewee and gets a missing value for the occupation in the current
> wave, assign his nonmissing occupation value when he was a new interviewee
> to the current occupation. That is, assign "3" to individual 1 in years 1999
> and 2000, assign "5" to individual 2 in years 1999 and 2000; assign value
> "4" to individual 3 in year 2000. The final data structure should be like:
>
> ID      year    Reinterviewee   occupation
> 1       1998    no                         3
> 1       1999    yes                        3
> 1       2000    yes                        3
> 2       1998    no                         5
> 2       1999    yes                        5
> 2       2000    yes                        5
> 3       1999    no                         4
> 3       2000    yes                        4
>
> Since there are too many individuals in the original data set, I need to
> program rather than reassigning values manually. Could you please tell me
> how I should program to realize such purpose?

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index