In the example below I have a dataset that looks like A and I wanna use STATA to reshape it to look like B. Or, even better, in an ideal world I would like it to be like C
A. THIS IS WHAT I HAVE
id | Mom income | Mom occupation | Mom birth year | Dad income | Dad occupation | Dad birth year | Child birth year | Child gender |
1 | 100 | Student | 1985 | 10 | Accountant | 1970 | 2010 | Male |
2 | 200 | Clerk | 1999 | 500 | Teacher | 1975 | 2012 | Male |
3 | 300 | Accountant | 1972 | 100 | Doctor | 1960 | 2019 | Female |
4 | 400 | Busdriver | 1653 | 700 | Student | 1980 | 2005 | Female |
B.
id | Family id | Mom income | Mom occupation | Mom birth year | Dad income | Dad occupation | Dad birth year | Child birth year | Child gender |
1 | 1 | 100 | Student | 1985 | |||||
2 | 1 | 10 | Accountant | 1970 | |||||
3 | 1 | 2012 | Male | ||||||
4 | 2 | 200 | Clerk | 1999 | |||||
5 | 2 | 500 | Teacher | 1975 | |||||
6 | 2 | 2012 | Male | ||||||
7 | 3 | 300 | Accountant | 1972 | |||||
8 | 3 | 100 | Doctor | 1960 | |||||
9 | 3 | 2019 | Female | ||||||
10 | 4 | 400 | Busdriver | 1653 | |||||
11 | 4 | 700 | Student | 1980 | |||||
12 | 4 | 2005 | Female |
C. THIS IS WHAT I REALLY WANT
id | Family id | type of member | Income | occupation | birth year | gender |
1 | 1 | mom | 100 | Student | 1985 | |
2 | 1 | dad | 10 | Accountant | 1970 | |
3 | 1 | child | 2010 | Male | ||
4 | 2 | mom | 200 | Clerk | 1999 | |
5 | 2 | dad | 500 | Teacher | 1975 | |
6 | 2 | child | 2012 | Male | ||
7 | 3 | mom | 300 | Accountant | 1972 | |
8 | 3 | dad | 100 | Doctor | 1960 | |
9 | 3 | child | 2019 | Female | ||
10 | 4 | mom | 400 | Busdriver | 1653 | |
11 | 4 | dad | 700 | Student | 1980 | |
12 | 4 | child | 2005 | Female |
Johanna
0 Response to Data stored with information on several individuals in one row. How to make each individual a unique observation?
Post a Comment