I am preparing a data set (Russian Longitudinal monitoring survey) for analysis. Individual and household data are merged - using household as master - based on year and family ID (id_h). I want to focus on household level but need some of the individual data as well.
I get the following error using the xtset (stata/SE 14.2 for windows)
. xtset id_h year
repeated time values within panel
r(451);
The error is probably due to the fact the there are multiple individuals that have been interviewed within the household. Unfortunately, I cleaned my data set and it would take a long time to merge individual with household data set again.
I have to get rid of the individuals in the household that did not report the cost of variable: A,B,C, or D. A difficulty arises when none of the individuals report any costs. Also, because it is a panel data set, it has to be year specific. if person 1 gave an amount of cost for one of the variables A, B, C, or D in 2004 I want to keep this person and get rid of the other individuals (that are in the same household and interviewed in the same year).
If none of the individuals report any costs, then I want to keep the individual who does Not have a value for idind.
I looked into the FAQ: How do I deal with a report of repeated time values within panel? Written by Nicholas J. Cox.
. duplicates list id_h year
. duplicates tag id_h year, gen(isdup)
But now I don't know how to keep the individual that reported costs for any of the variables or if no costs are reported drop the individuals with a value for idind.
Sorry, if it is a bit confusing and not written in proper format.
I get the following error using the xtset (stata/SE 14.2 for windows)
. xtset id_h year
repeated time values within panel
r(451);
The error is probably due to the fact the there are multiple individuals that have been interviewed within the household. Unfortunately, I cleaned my data set and it would take a long time to merge individual with household data set again.
I have to get rid of the individuals in the household that did not report the cost of variable: A,B,C, or D. A difficulty arises when none of the individuals report any costs. Also, because it is a panel data set, it has to be year specific. if person 1 gave an amount of cost for one of the variables A, B, C, or D in 2004 I want to keep this person and get rid of the other individuals (that are in the same household and interviewed in the same year).
If none of the individuals report any costs, then I want to keep the individual who does Not have a value for idind.
I looked into the FAQ: How do I deal with a report of repeated time values within panel? Written by Nicholas J. Cox.
. duplicates list id_h year
. duplicates tag id_h year, gen(isdup)
But now I don't know how to keep the individual that reported costs for any of the variables or if no costs are reported drop the individuals with a value for idind.
Sorry, if it is a bit confusing and not written in proper format.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input int year long(id_h idind OOP_Medicine) double(OOP_Inpatient OOP_Outpatient OOP_Dental_treatment) 2009 1001 1 . . . . 2009 1001 . . . . . 2009 1001 24101 . . . . 2009 1001 11293 . . . . 2009 1002 5 . . . . 2009 1002 . . . . . 2009 1003 7 . . . . 2009 1003 . . . . . 2009 1004 9 . . . . 2009 1004 . . . . . 2009 1006 11291 . . . . 2009 1006 . . . 6300 950 2009 1014 25031 . . . . 2009 1014 31360 . . . . 2009 1014 . . . 3000 . 2009 1021 14369 . . . . 2009 1021 29 . . . . 2009 1021 14370 . . . . 2009 1021 16255 . . . . 2009 1021 28 . . . . 2009 1021 . . . 1200 . 2009 1021 11296 . . . . 2009 1021 30 . . . . 2009 1036 25037 . . . . 2009 1036 . . . . . 2009 1036 25036 . . . . 2009 1037 25041 . . . . 2009 1037 . . 1500 1000 . 2009 1037 25039 . . . . 2009 1037 31343 . . . . 2009 1037 25040 . . . . 2009 1037 25038 . . . . 2009 1038 . . . . . 2009 1038 30123 . . . . 2009 1044 11328 . . . . 2009 1044 . . . 3336 15000 2009 1044 11329 . . . . end label values OOP_Medicine E13_3_1B label values OOP_Inpatient E13_22B label values OOP_Outpatient E13_23B label values OOP_Dental_treatment E13_24B
Comment