I have a survey data set (panel). In the dataset, I have a variable in which few numbers are wrongly entered. For example, if an establishment has started in a particular year (starting_year), the starting_year is not supposed to vary. In few of the years, the starting_year has been entered as 0. I have used the following commands to replace the wrongly entered values with the correct values but I am not able to replace it:
egen tag = tag(panel_id starting_year)
egen ndistinct = total(tag), by(panel_id)
bysort panel_id (starting_year) : replace starting_year = starting_year[_N] if missing(inityr) & ndistinct == 1
STATA result
(0 real changes made)
An analogous data file is attached. I would really appreciate the help.
Related Posts with Help in editing (replacing some values) a variable in panel data
Model's forecast accuracy evaluationHi everyone, I want to evaluate forecasting accuracy of ARIMA (1,1,1) model. I use only one variabl…
combining foreach and by with stringsHello, I found similar topics on the forum but the solutions provided do not seem to fit my case. …
unbalanced panelHi everyone I'm running a regression with fixed effects of individuals: reg y x i.firm i.year i.indi…
Finding max and min of a numbers' list stored in macroDear All, I am looking for a solution to find maximum and minimum numbers stored in a local/global …
Using suest to compare coefficientsHi statalist, I am running an ordinal regression model separately for each sex because I expect that…
Subscribe to:
Post Comments (Atom)
0 Response to Help in editing (replacing some values) a variable in panel data
Post a Comment