Please excuse this very beginner question, but much help would be appreciated!
I want to create a variable for all 2018 observations that indicates its value in 2017 (if there is a value there). I only want to go back to 2017, no further. If there's no value for 2017 or for 2018, the variable value should just be missing.
Using "if year==2017" doesn't work because then it just creates the variable for observations in 2017 (not 2018), and using "[_n-1]" doesn't work because then I think it may go back further than 2017 if there is a value available for an earlier year but not for 2017.
Thank you in advance!
Related Posts with Replace with previous value, but just 1 year back
Monthly Unemployment Rate Calculation for Two Groups of StatesHi, I am working on a project in which I have data from the CPS. I also have data that tells me when…
Need advice on recoding categorical variables into continuous variables and vice versaI am new to data analysis and Stata, so I apologise if I have not explained this very well. I have …
Consolidating two line graphs and editing X and Y axis labels and title on Line GraphHi, I am working with a dataset of 14 observations, and I am trying to make a line graph using these…
Stata 17- Percentages of the total sumHello Everyone, I have a list of individuals and their incomes. I have divided them into 5 quintiles…
testing difference between coefficients in different equationsI would like to run the following regressions: xtreg a x y z i.mth_seq, fe vce(robust) *equation 1 …
Subscribe to:
Post Comments (Atom)
0 Response to Replace with previous value, but just 1 year back
Post a Comment