Hi,
I am new to Stata and was wondering if someone could help me with following question:
I imported a census sample file using insheet, and now have a variable (v1) equal to one if the observation is at the family-level, and equal to zero if the observation is at the personal-level. So the data looks something like this (where . denotes missing information for a given variable):
Hence, family-level observations contain 2 variables (v2, v3), while personal-level observations contain 4 variables (v2, v3, v4, v5). Note that v2 and v3 for family-level records (v1==1) are not the same as v2 and v3 for personal level records (v1==0).
In the example above, there are 2 families: one with two individuals, and another one with one individual. I do not know how to link family-level characteristics to personal-level characteristics, but I want the dataset to look something like this:
That is, personal records now have a v6 that corresponds to v2 for family records, and a v7 that corresponds to v3 for family records.
I do not have id variables for families or individuals; the only way I know that a person is in a given family by looking at the dataset, is since a row containing family information is followed by the personal-level information of each of it's members. Any ideas how to do this in Stata?
I am new to Stata and was wondering if someone could help me with following question:
I imported a census sample file using insheet, and now have a variable (v1) equal to one if the observation is at the family-level, and equal to zero if the observation is at the personal-level. So the data looks something like this (where . denotes missing information for a given variable):
v1 | v2 | v3 | v4 | v5 |
1 | 1 | 2 | . | . |
0 | 3 | 4 | 5 | 6 |
0 | 7 | 8 | 9 | 10 |
1 | 11 | 12 | . | . |
0 | 13 | 14 | 15 | 16 |
Hence, family-level observations contain 2 variables (v2, v3), while personal-level observations contain 4 variables (v2, v3, v4, v5). Note that v2 and v3 for family-level records (v1==1) are not the same as v2 and v3 for personal level records (v1==0).
In the example above, there are 2 families: one with two individuals, and another one with one individual. I do not know how to link family-level characteristics to personal-level characteristics, but I want the dataset to look something like this:
v1 | v2 | v3 | v4 | v5 | v6 | v7 |
1 | 1 | 2 | . | . | . | . |
0 | 3 | 4 | 5 | 6 | 1 | 2 |
0 | 7 | 8 | 9 | 10 | 1 | 2 |
1 | 11 | 12 | . | . | . | . |
0 | 13 | 14 | 15 | 16 | 11 | 12 |
I do not have id variables for families or individuals; the only way I know that a person is in a given family by looking at the dataset, is since a row containing family information is followed by the personal-level information of each of it's members. Any ideas how to do this in Stata?
Comment