Hi, I am trying to replace/ drop an observation conditional on another variable. I want to drop every 5th row of observations in FLOWMutual/FLOWLret. As it is a panel data set with observations across time it caused overlap between periods of the change function I used. I've tried multiple codes using drop / replace etc but I can't for the life of me figure out how to fix it, even though it seems as such a simple task. Does anyone know how to tackle this or to perhaps modify the % change function below to not get the observations for the overlapping time periods? Thanks in advance!
FLOWMutual / FLOWLret function:
gen FLOW = (tna_latest - tna_latest[_n-1])/tna_latest[_n-1]*100
I have tried the codes below to no success:
replace FLOWMutual = . if turn_ratio = .
drop FLOWmutual if Date = 31dec2019
foreach x of varlist FLOWmutual turn_ratio{replace `FLOWMutual' = 0 if (`turn_ratio' = .)}
FLOWMutual / FLOWLret function:
gen FLOW = (tna_latest - tna_latest[_n-1])/tna_latest[_n-1]*100
I have tried the codes below to no success:
replace FLOWMutual = . if turn_ratio = .
drop FLOWmutual if Date = 31dec2019
foreach x of varlist FLOWmutual turn_ratio{replace `FLOWMutual' = 0 if (`turn_ratio' = .)}
Comment