Hi,
I have a data set that uniquely defines a household via 2 variables: conglome vivienda
Within a household, codperso identifies individuals.
A variable p210 tells me if a person has a spouse living in the same household.
I would like to delete all observations that have households with more than 2 individuals who have a spouse in the household i.e. households with more than one married couple living in it.
I have done the following so far:
. sort conglome vivienda
. quietly by conglome vivienda: gen dup = cond(_N==1,0,_n) if p210==1
. tabulate dup
dup Freq. Percent Cum.
0 15 1.13 1.13
1 618 46.64 47.77
2 618 46.64 94.42
3 41 3.09 97.51
4 33 2.49 100.00
Essentially, for any household that has dup reaching 3 or 4, I want to delete all observations in that household (not just the observations for which dup == 3 | dup == 4).
Could anyone advise on a solution?
Thank you!
Related Posts with Remove observations when there are more than 2 rows with the same ID
estpost correlate command for time series operatorsDear Stata members I would like to do a correlation analysis with some lag values and -estpost corre…
ODBC, *Stata 16 and Big SurHello, After updating to MacOS BigSur 11.1.3, i am now facing the following problem with Stata 16 a…
RDD H-ATE with RDROBUSTDear STATALISTs, I am intereset to find a h-ate in a RDD model. In particular, I would like to know…
Post-estimation of ordered logit regression.Hi All, I am currently working on a project for my degree using Stata 16. In my research I am attem…
Problem with the option xline with the user-written command coefplotDear all, I am currently working with Stata 16.1 on an event study analysis. I am having troubles w…
Subscribe to:
Post Comments (Atom)
0 Response to Remove observations when there are more than 2 rows with the same ID
Post a Comment