Hello everyone,
I have a dataset for over 600 households. Here's an example of it:
Key | Parent | hh_members_count | Index | name | age
123AA57begs Sofia 3 1 Sam 37
123AA57begs Sofia 3 2 Nancy 15
123AA57begs Sofia 3 3 Mark 2
983aM04bb5z Karma 3 1 Joseph 38
983aM04bb5z Karma 3 2 Hariot 4
983aM04bb5z Karma 3 3 Kevin 1.5
I would like to create a random variable called hhid that repeats for each individual but at the same time is unique for each household. Here's an example:
Key | Parent | hh_members_count | Index | name | age | hhid
123AA57begs Sofia 3 1 Sam 37 2517
123AA57begs Sofia 3 2 Nancy 15 2517
123AA57begs Sofia 3 3 Mark 2 2517
983aM04bb5z Karma 3 1 Joseph 38 3089
983aM04bb5z Karma 3 2 Hariot 4 3089
983aM04bb5z Karma 3 3 Kevin 1.5 3089
The hhid shouldn't be cumulative (i.e. not 1, 2, 3...). Also it should have a minimum of 3 numbers and a maximum of 5 numbers. In other words the hhid should be as unique as the key except that it takes numerical values only.
I would greatly appreciate your help in this regard. Thank you.
I have a dataset for over 600 households. Here's an example of it:
Key | Parent | hh_members_count | Index | name | age
123AA57begs Sofia 3 1 Sam 37
123AA57begs Sofia 3 2 Nancy 15
123AA57begs Sofia 3 3 Mark 2
983aM04bb5z Karma 3 1 Joseph 38
983aM04bb5z Karma 3 2 Hariot 4
983aM04bb5z Karma 3 3 Kevin 1.5
I would like to create a random variable called hhid that repeats for each individual but at the same time is unique for each household. Here's an example:
Key | Parent | hh_members_count | Index | name | age | hhid
123AA57begs Sofia 3 1 Sam 37 2517
123AA57begs Sofia 3 2 Nancy 15 2517
123AA57begs Sofia 3 3 Mark 2 2517
983aM04bb5z Karma 3 1 Joseph 38 3089
983aM04bb5z Karma 3 2 Hariot 4 3089
983aM04bb5z Karma 3 3 Kevin 1.5 3089
The hhid shouldn't be cumulative (i.e. not 1, 2, 3...). Also it should have a minimum of 3 numbers and a maximum of 5 numbers. In other words the hhid should be as unique as the key except that it takes numerical values only.
I would greatly appreciate your help in this regard. Thank you.
Comment