Provided data is a one-day travel data already sorted according to sampn (household id), perno (person id) and plano (place id). Now, I would like to know, how many children (age <18) visited with a given person (perno) for any specific place (plano). Age of all person in a household is given in a separate variable. Maximum 5 person can visit with that person which are given in (PER1 PER2 PER3 PER4 PER5). First example from the given data, in sampn 1032036 for place 2 (plano), person 1 (perno) traveled with person 4 and person 5 (given in PER1 PER2 variables). If I go down a little bit, I can see, the age of person 4 and person 5 of that household (1032036) is 14 years and 7 years respectively. So, in sampn 1032036 for place 2 (plano), person 1 (perno) has traveled with 2 children (age<18). For the same person of that household, for place 3, he traveled with person 2,3,4 and 5 , where number of children is three (as person 3 age is 15 years).
So, how can I do this for each sampn, perno, plano to find out the number of children (age<18) visited with a given person (I am not concerned with the given person age)?
Thanks
Rabiul
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input long sampn byte perno int age byte(plano PER1 PER2 PER3 PER4 PER5) 1032036 1 46 1 . . . . . 1032036 1 46 2 4 5 . . . 1032036 1 46 3 2 3 4 5 . 1032036 1 46 4 2 . . . . 1032036 1 46 5 2 . . . . 1032036 1 46 6 2 . . . . 1032036 2 47 1 . . . . . 1032036 2 47 2 . . . . . 1032036 2 47 3 . . . . . 1032036 2 47 4 . . . . . 1032036 2 47 5 3 . . . . 1032036 2 47 6 3 . . . . 1032036 2 47 7 3 . . . . 1032036 2 47 8 . . . . . 1032036 2 47 9 . . . . . 1032036 2 47 10 . . . . . 1032036 2 47 11 . . . . . 1032036 2 47 12 1 3 4 5 . 1032036 2 47 13 1 . . . . 1032036 2 47 14 1 . . . . 1032036 2 47 15 1 . . . . 1032036 2 47 16 . . . . . 1032036 2 47 17 . . . . . 1032036 2 47 18 . . . . . 1032036 2 47 19 . . . . . 1032036 3 15 1 . . . . . 1032036 3 15 2 2 . . . . 1032036 3 15 3 2 . . . . 1032036 3 15 4 2 . . . . 1032036 3 15 5 1 2 4 5 . 1032036 4 14 1 . . . . . 1032036 4 14 2 1 5 . . . 1032036 4 14 3 1 2 3 5 . 1032036 5 7 1 . . . . . 1032036 5 7 2 1 4 . . . 1032036 5 7 3 1 2 3 4 . 1032053 1 30 1 . . . . . 1032053 1 30 2 3 4 5 . . 1032053 1 30 3 . . . . . 1032053 1 30 4 2 6 . . . 1032053 1 30 5 2 6 . . . 1032053 1 30 6 2 6 . . . 1032053 1 30 7 2 6 . . . 1032053 1 30 8 2 6 . . . 1032053 1 30 9 2 6 . . . 1032053 1 30 10 . . . . . 1032053 1 30 11 3 4 5 . . 1032053 1 30 12 5 . . . . 1032053 1 30 13 . . . . . 1032053 1 30 14 3 4 . . . 1032053 1 30 15 2 3 4 5 6 1032053 1 30 16 2 3 4 5 6 1032053 2 31 1 . . . . . 1032053 2 31 2 1 6 . . . 1032053 2 31 3 1 6 . . . 1032053 2 31 4 1 6 . . . 1032053 2 31 5 1 6 . . . 1032053 2 31 6 1 6 . . . 1032053 2 31 7 1 6 . . . 1032053 2 31 8 1 3 4 5 6 1032053 2 31 9 1 3 4 5 6 1032053 3 9 1 . . . . . 1032053 3 9 2 1 4 5 . . 1032053 3 9 3 1 4 5 . . 1032053 3 9 4 1 4 . . . 1032053 3 9 5 1 2 4 5 6 1032053 3 9 6 1 2 4 5 6 1032053 4 7 1 . . . . . 1032053 4 7 2 1 3 5 . . 1032053 4 7 3 1 3 5 . . 1032053 4 7 4 1 3 . . . 1032053 4 7 5 1 2 3 5 6 1032053 4 7 6 1 2 3 5 6 1032053 5 5 1 . . . . . 1032053 5 5 2 1 3 4 . . 1032053 5 5 3 1 3 4 . . 1032053 5 5 4 1 . . . . 1032053 5 5 5 1 2 3 4 6 1032053 5 5 6 1 2 3 4 6 1032053 6 1 1 . . . . . 1032053 6 1 2 1 2 . . . 1032053 6 1 3 1 2 . . . 1032053 6 1 4 1 2 . . . 1032053 6 1 5 1 2 . . . 1032053 6 1 6 1 2 . . . 1032053 6 1 7 1 2 . . . 1032053 6 1 8 1 2 3 4 5 1032053 6 1 9 1 2 3 4 5 1032425 1 55 1 . . . . . 1032425 2 17 1 . . . . . 1032558 1 62 1 . . . . . 1032558 1 62 2 . . . . . 1032558 1 62 3 . . . . . 1032558 1 62 4 . . . . . 1032558 1 62 5 . . . . . 1032558 1 62 6 . . . . . 1032558 1 62 7 . . . . . 1033586 1 66 1 . . . . . 1033586 1 66 2 2 . . . . 1033586 1 66 3 2 . . . . end
0 Response to How to find out the number of children (<18 years) travelling with a given person for any specific place visited (Data provided)
Post a Comment