I am using Stata 16 on a MacOS High Sierra (Version: 10.13.6).
I have a question on how to rearrange a dataset for which I could not find a solution with a simple reshape. I have a dataset with 3 variables:
1. The family id : family_id
2. The name of the member of the family: name
3. The id of each single member within a family: member_id
My data look like this:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input byte member_id str8 name byte family_id 1 "Gaia" 1 2 "Jared" 1 3 "Ashley" 1 4 "Afsana" 1 1 "Edwin" 2 2 "Aaron" 2 1 "Carol" 3 2 "Kevin" 3 3 "Josh" 3 1 "Rachel" 4 2 "Erin" 4 3 "Luke" 4 4 "Agatha" 4 5 "Karen" 4 1 "Samantha" 5 2 "Eric" 5 1 "Ramon" 6 2 "Rosalia" 6 3 "Miguel" 6 1 "Amanda" 7 2 "Ross" 7 3 "Stacey" 7 4 "Colin" 7 5 "Govind" 7 6 "Finn" 7 end
So for example, the first family in this dataset will have other 3 variables (member_id2, member_id3, member_id4) correspondent to the other members.
Visually, I would have to have something like this for the first family:
Code:
input byte member_id str8 name byte family_id byte member_id2 member_id3 member_id4 1 "Gaia" 1 2 3 4 2 "Jared" 1 1 3 4 3 "Ashley" 1 1 2 4 4 "Afsana" 1 1 2 3
Thank you very much in advance!
0 Response to Question on how to rearrange household data
Post a Comment