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?
Cross sectional dependence for firm panel dataDo we conduct a cross sectional dependence test for panel data with N being listed firms and T being…
By ID_number, keep registry-based (baseline=0) test dates obtained 1 year after original (baseline=1) study’s test dateReally need help! With the expert guidance of a statistician, I merged (using the append command) a …
Dropping observations based on a list of IDHello, Is there a way to drop observations using a list of IDs ? I have a dataset and there are sev…
Unconditional cross-nested 4-level modelDear all, I would like to replicate a paper (https://onlinelibrary.wiley.com/doi/10.1002/smj.3057) …
How to Modify Stata Data (Dta file) using python code and save changes back to the dta fileI have 2000 observations and 100 variables in my data from an empirical research project. I am curre…
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