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
Macro indicatorHello, I have a question concerning a macro indicator included in my Random-Effects Modell. I am stu…
Problems with the ppplot command and resulting graphHi Statalisters, I faced a problem with the ppplot command by Nicholas J. Cox. First, I want to ed…
Passing arguments to mata functionsArray why is there two arguments needed in the functions?What does touse stand for?I don't understan…
Dark modeHi everyone I have a basic question about lay-out. I really like the dark mode option, but when cho…
Estimation of 5-year Cumulative incidence proportions stratified by age, sex and comorbiditiesHi Stata forum, I try to post once more regarding my problem - now hopefully its easier to read my c…
Subscribe to:
Post Comments (Atom)
0 Response to Replace with previous value, but just 1 year back
Post a Comment