Hello, I am trying to replace the missing values for all variables for an observation using the values from a subsequent observation. Below is the code that I am using.
ds
local allvar `r(varlist)'
foreach cc of local allvar {
bys id: replace "`cc'"[_n] = "`cc'"[_n+1] if dup == 1 & missing("`cc'"[_n]) & !missing("`cc'"[_n+1]) & check == 1 & max_dup == 2
}
When I run this code, however, I encounter an invalid name error shown here as: "date invalid name - date here is the first variable in my list of variables. Any and all help is highly appreciated.
ds
local allvar `r(varlist)'
foreach cc of local allvar {
bys id: replace "`cc'"[_n] = "`cc'"[_n+1] if dup == 1 & missing("`cc'"[_n]) & !missing("`cc'"[_n+1]) & check == 1 & max_dup == 2
}
When I run this code, however, I encounter an invalid name error shown here as: "date invalid name - date here is the first variable in my list of variables. Any and all help is highly appreciated.
Comment