Hi all,
I had a question about how to approach my data problem. I start with a file that is child-parent level. In image 1, "hhidpn" uniquely represents respondents while "kidid" represents children. The file is wide such that "k5age" is the child's age at wave 5 and "k6age" is the child's age at wave 6. I start by converting this to a long format file such that parent-child pairs each have 8 observations (since I am only interested in waves 5-12). This is shown in image 2.
For the final step, my goal is to have this be a respondent level file instead of respond-kid file. In Image 3, you can see where I currently stand. I have parent-child rows, but I want these to be merged. In the image, I have circled the cells that I would like to match up. In this case, kidid would become irrelevant and now, keduc1 would be the education of child 1, keduc2 the education of child 2, etc. I've tried using "collapse(firstnm)" by 'hhidpn and wave." This works, but the missing codes are important. For example, when collapsing, ".p" and ".n" simply become ".". I could convert these to numbers, collapse, and then reconvert, but I have many different extended missing codes and they mean different things for different variables. Alternatively, is there anyway to make Stata not read ".p" ".m" etc as missing? In an ideal world, if only "." counted as missing, I would have no issue.
Does anyone have any suggestions? I apologize is this is convoluted.
As a final note, the missing patterns are random throughout the data. Some respondents have almost every wave, some have none.
Image 1
Array
Image 2
Array
Image 3
Array
Related Posts with Collapsing observations in longitudinal data
Running a Regression with a Dummy Variable (1,0)Hello everyone, I work on a regression and I am not quite sure how to code it properly. Basically m…
If else loop in StataHi, I wrote a code like if x=="x1"|x=="x2" { replace z=y replace a=b } However, it did not work. I…
The percentage of independent directors on the boardHi everyone, For my research I need 1 more control variable. I need a control variable which equals…
How can I make a look to count the number of household member whose age is under 18?Hello, I am trying to generate the variable that captures the number of members whose age is under …
SEM: Panel analysesDear all, I´m using data from a Panel Study and working with two main latent variables (X and Y) th…
Subscribe to:
Post Comments (Atom)
0 Response to Collapsing observations in longitudinal data
Post a Comment