I have a dataset (example below) where I use the command "append" to add the datasets: i_indresp, ce_indresp_w and cg_indresp_w.
I nee to use the example of commands below to prepare the data in order to be a longitudinal data. However, I´m having dificulties in using this code to achieve the required results. Can you help me with this?
Code that I need to use.
foreach w in a b c d e {
use `w'_indresp, clear
renpfix `w'_
gen wave=strpos("abcde", "`w'")
save temp`w', replace
}
Example dataset:
Code:
* Example generated by -dataex-. For more info, type help dataex clear input long(pidp pid i_hidp) byte(i_pno i_sex) int i_dvage byte(cg_sex_cv ce_sex_cv ce_scghqa i_scghqa cg_scghqa cg_scghqd cg_scghqe) 22445 10127798 277344816 1 2 33 . . . 2 . . . 29925 10192697 619024416 1 2 40 . . . 1 . . . 76165 10689869 141657616 1 2 34 . . . 2 . . . 280165 12430439 754793216 1 2 38 . . . 2 . . . 333205 12908843 415106696 1 2 26 . . . 2 . . . 469205 13857142 415059096 1 2 27 . . . 2 . . . 599765 14757249 211282816 1 2 30 . . . 2 . . . 732365 15752658 619371216 1 1 32 . . . 4 . . . 1587125 17870879 618269616 1 2 51 . . . 2 . . . 1697285 42526507 210766016 1 1 44 . . . 2 . . . 1833965 50832336 753508016 1 1 52 . . . 2 . . . 2270525 76446336 823677216 1 2 20 . . . 3 . . . 2626845 93565895 822997216 1 1 39 . . . 2 . . . 2888645 96949503 76479616 1 2 28 . . . 2 . . . 3587685 118781707 483813216 1 1 36 . . . -7 . . . 3663845 119065835 416323216 1 1 33 . . . -8 . . . 3667245 119074613 280309616 1 2 29 . . . 4 . . . 3705325 119277506 144867216 1 2 63 . . . 2 . . . 4454005 154358304 482840816 1 1 72 . . . 2 . . . 4849085 176725733 347554816 1 1 34 . . . 4 . . . 4853165 176977635 824289216 1 1 47 . . . 2 . . . 68002045 10017933 73018416 1 2 74 . . . -8 . . . 68002725 10023526 73025216 1 2 63 . . . 2 . . . 68004087 -8 68006816 1 1 67 . . . 2 . . . 68006127 -8 68013616 1 2 47 . . . 2 . . . 68006807 -8 68034016 1 2 80 . . . 3 . . . 68008847 -8 68040816 1 2 59 . . . 3 . . . 68009527 -8 68047616 1 1 39 . . . 2 . . . 68010887 -8 68054416 1 2 53 . . . 2 . . . 68011567 -8 68061216 1 1 43 . . . 2 . . . 68020407 -8 68095216 1 2 80 . . . 2 . . . 68020564 -8 68013616 2 1 46 . . . 3 . . . 68021765 10200436 73032016 1 2 58 . . . 4 . . . 68021781 30139368 73032016 2 1 23 . . . 2 . . . 68028567 -8 68108816 1 2 46 . . . 3 . . . 68028571 -8 68108816 2 1 50 . . . 2 . . . 68028575 -8 68129216 1 2 26 . . . 2 . . . 68029927 -8 68136016 1 2 45 . . . 2 . . . 68029931 -8 68136016 2 1 48 . . . 2 . . . 68031967 -8 68142816 1 2 69 . . . 2 . . . 68035365 10403086 73045616 1 1 65 . . . 2 . . . 68035367 -8 68156416 1 1 36 . . . 2 . . . 68036727 -8 68163216 1 1 85 . . . 2 . . . 68037407 -8 68170016 1 2 48 . . . 2 . . . 68041487 -8 68176816 1 2 47 . . . 3 . . . 68041491 -8 68176816 2 1 44 . . . 1 . . . 68042167 -8 68183616 1 1 47 . . . 2 . . . 68042171 -8 68183616 2 2 46 . . . 2 . . . 68043527 -8 68190416 1 1 63 . . . 2 . . . 68044207 -8 68197216 1 2 42 . . . 3 . . . 68044211 -8 68197216 2 1 44 . . . 2 . . . 68044887 -8 68204016 1 2 70 . . . 2 . . . 68045567 -8 68210816 1 2 55 . . . 1 . . . 68045571 -8 68210816 2 1 57 . . . 2 . . . 68046927 -8 68231216 1 2 44 . . . 2 . . . 68046935 -8 68231216 2 2 17 . . . 2 . . . 68048287 -8 68238016 1 1 70 . . . 2 . . . 68049647 -8 68244816 1 1 59 . . . 2 . . . 68049651 -8 68244816 2 2 57 . . . 2 . . . 68051007 -8 68251616 1 1 56 . . . 1 . . . 68051011 -8 68251616 2 2 49 . . . 3 . . . 68056447 -8 68258416 1 1 54 . . . 3 . . . 68056451 -8 68258416 2 2 52 . . . 2 . . . 68056455 -8 68265216 1 2 22 . . . 3 . . . 68056459 -8 68258416 3 2 17 . . . 2 . . . 68058485 10628126 73052416 1 1 72 . . . 2 . . . 68058487 -8 68272016 1 1 77 . . . 2 . . . 68058489 10628169 73052416 2 2 72 . . . 2 . . . 68058491 -8 68272016 2 2 68 . . . 3 . . . 68059171 -8 68278816 1 2 27 . . . 2 . . . 68060525 10641556 73059216 1 1 90 . . . 3 . . . 68060527 -8 68285616 1 1 43 . . . 2 . . . 68060531 -8 68285616 2 2 44 . . . 2 . . . 68060533 160066204 73059216 2 2 61 . . . 3 . . . 68060537 160066239 73059216 3 1 73 . . . 2 . . . 68061288 -8 68047616 2 2 31 . . . 2 . . . 68063247 -8 68292416 1 2 50 . . . 2 . . . 68063251 -8 68292416 2 1 52 . . . 2 . . . 68063255 -8 68292416 3 1 17 . . . 1 . . . 68063927 -8 68299216 1 2 47 . . . 2 . . . 68063931 -8 68299216 2 1 49 . . . 2 . . . 68064605 10653872 73066016 1 1 68 . . . 2 . . . 68064609 10653902 73066016 2 2 65 . . . 2 . . . 68068007 -8 68326416 1 1 50 . . . 2 . . . 68068011 -8 68326416 2 2 50 . . . 2 . . . 68068015 -8 68327096 1 2 25 . . . 2 . . . 68068082 -8 68054416 2 1 56 . . . 2 . . . 68069367 -8 68333216 1 1 89 . . . 2 . . . 68071407 -8 68340016 1 1 28 . . . 2 . . . 68072087 -8 68346816 1 1 63 . . . 2 . . . 68076167 -8 68360416 1 2 68 . . . 3 . . . 68076171 -8 68360416 2 1 71 . . . 2 . . . 68086371 -8 68367216 1 2 28 . . . 2 . . . 68087727 -8 68380816 1 2 67 . . . 2 . . . 68090447 -8 68387616 1 2 64 . . . 2 . . . 68091127 -8 68394416 1 2 43 . . . 3 . . . 68091135 -8 68401216 1 2 20 . . . 4 . . . 68091139 -8 68394416 2 1 18 . . . 3 . . . 68097245 10913629 73072816 1 2 67 . . . 2 . . . 68097927 -8 68421616 1 2 68 . . . 2 . . . end label values pid pid label def pid -8 "inapplicable", modify label values i_sex i_sex label def i_sex 1 "male", modify label def i_sex 2 "female", modify label values i_dvage i_dvage label values cg_sex_cv cg_sex_cv label values ce_sex_cv ce_sex_cv label values ce_scghqa ce_scghqa label values i_scghqa i_scghqa label def i_scghqa -8 "inapplicable", modify label def i_scghqa -7 "proxy", modify label def i_scghqa 1 "Better than usual", modify label def i_scghqa 2 "Same as usual", modify label def i_scghqa 3 "Less than usual", modify label def i_scghqa 4 "Much less than usual", modify label values cg_scghqa cg_scghqa label values cg_scghqd cg_scghqd label values cg_scghqe cg_scghqe
0 Response to Create dataset - longitudinal
Post a Comment