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
Reshaping data from wide to longWhen I try to reshape I keep getting this error r(111) no xij variables found You typed something li…
Ordering legend only in graphI am trying to order the legend with the better outcome group up top in the legend and the worse out…
eclass store resultsDear stata users, I would like to store a matrix and the number of observations after my eclass pro…
unknown function () in a simple generate commandHi, I am trying to generate a new variable b with the following formula using all existing variable…
Draw a stratified random sampleHi, I am working with a survey where I have information at the individual and household levels. I s…
Subscribe to:
Post Comments (Atom)
0 Response to Replace with previous value, but just 1 year back
Post a Comment