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
label defineHey guys, I tried this command label define currmarr 0 "no currently legally married" 1 "currently …
Calculating Risk for Repeated Measures with Varying & Overlapping PredictorsI have data on several measures for 150 survey respondents: Infection (binary outcome of interest), …
declare survey design for datasetHello, I have a question regarding how to correctly declare survey design for a dataset I am analyz…
Generalized difference in differences problemI am evaluating a government program using difference in differences. The program was implemented in…
Interpretation of terms in discontinuous growth model – mixed commandHello everyone, I am estimating a discontinuous growth curve model for a study about the impact of …
Subscribe to:
Post Comments (Atom)
0 Response to Help in editing (replacing some values) a variable in panel data
Post a Comment