Hello,
I have a similar question as in https://www.statalist.org/forums/for...same-household which has not been resolved yet.
Below I show data of 3 variables: the interview year (int_year), the year the household moved into the house (hhmove) and if the house has a pool (poolacc; 1=yes, 2= no).
FYI: the data comes from the American Housing Survey, which interviews the same houses every 2 years.
For variables of other housing characteristics I have values for all interview years (2001-2011), except for variable 'poolacc'. For this variable, only values in 2011 are available.
I am trying to impute/copy the same values of poolacc of int_year=2011 to the other interview years as my mentor has instructed me (assuming the houses always had or did not have a pool in the years before).
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float int_year int hhmove byte poolacc 2009 2008 . 2009 2007 . 2009 2007 . 2009 2008 . 2009 2007 . 2009 2007 . 2009 2007 . 2009 2007 . 2009 2007 . 2009 2008 . end
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float int_year int hhmove byte poolacc 2011 2009 2 2011 2010 2 2011 2009 2 2011 2010 1 2011 2009 2 2011 2010 2 2011 2011 1 2011 2009 1 2011 2010 2 2011 2009 2 end
Thanks in advance!
Related Posts with How can I copy values for a variable to other observations within the same variable?
Identification of Treatment and Control GroupRespected members, I am trying to employ DID as a means of analysis. In my dataset of 287 firms bet…
Removing NA Across varI have data in string as shown below data1 data2 NA NA NA NA NA NA NA 8415739 NA 10024002 N 1205788…
Generate var using sequential variables namesHi everyone, p1_1 p1_2 p1_3 p2_1 p2_2 p2_3 p3_1 p3_2 p3_3 1 1 1 2 2 2 3 3 3 1 1 1 2 2 2 3 3 3 1 1 …
Split string variableDear Experts, I want to split the string variable. Please advice. The issue is: I have the respons…
Generate sum of variables with sequential variables namesHi everyone, I have a data with these sequential variable names. p1_1_1_1 p1_1_1_2 p1_1_1_3 p1_1…
Subscribe to:
Post Comments (Atom)
0 Response to How can I copy values for a variable to other observations within the same variable?
Post a Comment