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
Verify that differences across countries are not driven by sample sizeI am analyzing data from a survey experiment in three countries. The sample size differs across coun…
Do I need to standardize a mixed data before doing lasso?Hello people, I have a great data of mixed variables: binary variables, quantitative variables and …
Survival analysis: First year the earlier 1 and Last year the later 1I need your help for survival study. Background: I have corporate panel data set as Corporate codes…
csv file-separating columnsHi all, I have around 1000 csv files and I need to import them into STATA - the columns are not sepa…
Simplifying loop in mataDear all, I'm running iteration in Mata until the difference between the sum of previous weight mat…
Subscribe to:
Post Comments (Atom)
0 Response to Remove observations when there are more than 2 rows with the same ID
Post a Comment