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
Missing value fill-in with data from specific datesI have data on migration numbers between countries and their neighbors. The issue is that the data i…
Filling in Values in Panel Data Above and Below with Unique OrdersDear Stata Users, I am in the process of cleaning data on historical greenhouse gas emissions. Sinc…
Cleaning of dataHi, I am working with a set of panel data and are trying to do some cleaning of my data so that I ca…
treated unit not found in panelvar - check tr(). error helpHello, I am using the synth.ado file and I am attempting to run a placebo test and I continue to ge…
Multilevel Zero inflated negative binomial regression?Hi All, I am running a negative binomial regression within a multilevel framework using the meglm co…
Subscribe to:
Post Comments (Atom)
0 Response to Replace with previous value, but just 1 year back
Post a Comment