Hello All,
My data are in long format. Each participant has 22 survey cycles. I have two variables that I want to combine into one variable. The first variable has data from survey cycle 8 to 11 and the 2nd one has data from survey cycle 15 to 18. In the new variable, I want the information from survey cycles 8-11 to be written for survey cycle 12, and the information from survey cycles 15-18 to be written for survey cycle 19. See the data example below:
For this first participant I want 15.75 to be written under meanpriormpa for sc 12, and 10 to be written for sc 19. I have succeeded at doing this by transforming my files to wide, calculating the mean variables i want. Recoding the sc to 12 or 19 to remerge the file with the original files. To me this seems like a very long road to get what I want. Does anyone have an approach that would be a lot quicker?
Thank you
Patrick
My data are in long format. Each participant has 22 survey cycles. I have two variables that I want to combine into one variable. The first variable has data from survey cycle 8 to 11 and the 2nd one has data from survey cycle 15 to 18. In the new variable, I want the information from survey cycles 8-11 to be written for survey cycle 12, and the information from survey cycles 15-18 to be written for survey cycle 19. See the data example below:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input byte sc float(meanpriormpa12 meanpriormpa19 meanpriormpa) 1 . . . 2 . . . 3 . . . 4 . . . 5 . . . 6 . . . 7 . . . 8 15.75 . . 9 15.75 . . 10 15.75 . . 11 15.75 . . 12 . . . 13 . . . 14 . . . 15 . 10 . 16 . 10 . 17 . 10 . 18 . 10 . 19 . . . end
Thank you
Patrick
Comment