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]

st: change variable values in panel data


From   xueliansharon <[email protected]>
To   [email protected]
Subject   st: change variable values in panel data
Date   Sat, 16 Jun 2012 15:36:26 -0700 (PDT)

Dear all,

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?

Your help will be greatly appreciated!

Many thanks!

Best,
Xuelian 


--
View this message in context: http://statalist.1588530.n2.nabble.com/change-variable-values-in-panel-data-tp7580206.html
Sent from the Statalist mailing list archive at Nabble.com.
*
*   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