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
Multilevel model (binary outcome) with spatial weight matrix (not panel data)Hi Stata forum users, Does stata have any option to incorporate a spatial weight matrix with melogi…
Stata technique for CPPMLHello, does anyone have practical experience in Stata with Constrained Poisson Pseudo Maximum Likel…
How to sum variable by year for specific group idThe original dataset has the following structure: group_id | year | varx 1 1998 5 1 1998 5 1 1999 2…
xtabond2Hello everyone, I am currently working with dynamic panel data. The model I want to estimate using …
Question about stsplitHi all, I would like to write a command to stsplit a dataset thus: Code: stsplit newvar, at(date…
Subscribe to:
Post Comments (Atom)
0 Response to Help in editing (replacing some values) a variable in panel data
Post a Comment