Hi, guys
I have a database with data in long format where each child (id) has a food consumption record and several anthropometry records. I have already calculated the distance between the dates of recording food consumption and anthropometry (inter_caen variable). I would like to identify anthropometry records that are 1 year (10 to 14 months), 2 years (22 to 26 months) and 3 years (34 to 38 months) after the food consumption record for this child. Furthermore, I would like to choose only the first record from each of these periods. In other words, in the end, I would like to set up a wide database that has the measurement of food consumption, accompanied by the three anthropometric records in these periods (1, 2 and 3 years). T
To do this, I created the variable for each age of interest (1, 2 and 3 years), but I am unable to progress after that. Below is the example of an ID with 95 anthropometry records and see that this child has records in these 3 ranges of interest. How to do this systematically for all ids? Children who do not have all 3 records at these times will be excluded. Could you help me move forward with assembling this database? I use Stata version 17.
I thank the help of all you.
----------------------- copy starting from the next line -----------------------
------------------ copy up to and including the previous line ------------------
I have a database with data in long format where each child (id) has a food consumption record and several anthropometry records. I have already calculated the distance between the dates of recording food consumption and anthropometry (inter_caen variable). I would like to identify anthropometry records that are 1 year (10 to 14 months), 2 years (22 to 26 months) and 3 years (34 to 38 months) after the food consumption record for this child. Furthermore, I would like to choose only the first record from each of these periods. In other words, in the end, I would like to set up a wide database that has the measurement of food consumption, accompanied by the three anthropometric records in these periods (1, 2 and 3 years). T
To do this, I created the variable for each age of interest (1, 2 and 3 years), but I am unable to progress after that. Below is the example of an ID with 95 anthropometry records and see that this child has records in these 3 ranges of interest. How to do this systematically for all ids? Children who do not have all 3 records at these times will be excluded. Could you help me move forward with assembling this database? I use Stata version 17.
I thank the help of all you.
----------------------- copy starting from the next line -----------------------
Code:
* Example generated by -dataex-. For more info, type help dataex clear input long id byte(leite_peito_6m_2a_ca hamburguer_6m_2a_ca) float(seq_CAEN dataacomp_ca dataacomp_en inter_caen_meses fx_etaria_caen1 fx_etaria_caen2 fx_etaria_caen3) 123555567 0 0 1 20507 20436 -2.3471074 . . . 123555567 0 0 2 20507 20472 -1.1570247 . . . 123555567 0 0 3 20507 20545 1.2561984 . . . 123555567 0 0 4 20507 20580 2.413223 . . . 123555567 0 0 5 20507 20622 3.801653 . . . 123555567 0 0 6 20507 20636 4.264463 . . . 123555567 0 0 7 20507 20667 5.289256 . . . 123555567 0 0 8 20507 20671 5.421488 . . . 123555567 0 0 9 20507 20744 7.834711 . . . 123555567 0 0 10 20507 20769 8.661157 . . . 123555567 0 0 11 20507 20795 9.520661 . . . 123555567 0 0 12 20507 20800 9.68595 . . . 123555567 0 0 13 20507 20825 10.512397 1 . . 123555567 0 0 14 20507 20856 11.53719 1 . . 123555567 0 0 15 20507 20886 12.528926 1 . . 123555567 0 0 16 20507 20914 13.454545 1 . . 123555567 0 0 17 20507 20921 13.68595 1 . . 123555567 0 0 18 20507 20972 15.3719 . . . 123555567 0 0 19 20507 20976 15.504132 . . . 123555567 0 0 20 20507 20992 16.033058 . . . 123555567 0 0 21 20507 21007 16.528925 . . . 123555567 0 0 22 20507 21035 17.454546 . . . 123555567 0 0 23 20507 21088 19.20661 . . . 123555567 0 0 24 20507 21108 19.86777 . . . 123555567 0 0 25 20507 21124 20.396694 . . . 123555567 0 0 26 20507 21154 21.38843 . . . 123555567 0 0 27 20507 21159 21.55372 . . . 123555567 0 0 28 20507 21165 21.752066 . . . 123555567 0 0 29 20507 21166 21.785124 . . . 123555567 0 0 30 20507 21167 21.81818 . . . 123555567 0 0 31 20507 21172 21.98347 . . . 123555567 0 0 32 20507 21174 22.04959 . 1 . 123555567 0 0 33 20507 21223 23.66942 . 1 . 123555567 0 0 34 20507 21242 24.29752 . 1 . 123555567 0 0 35 20507 21244 24.363636 . 1 . 123555567 0 0 36 20507 21262 24.95868 . 1 . 123555567 0 0 37 20507 21276 25.42149 . 1 . 123555567 0 0 38 20507 21277 25.454546 . 1 . 123555567 0 0 39 20507 21283 25.652893 . 1 . 123555567 0 0 40 20507 21284 25.68595 . 1 . 123555567 0 0 41 20507 21298 26.14876 . . . 123555567 0 0 42 20507 21311 26.57851 . . . 123555567 0 0 43 20507 21312 26.61157 . . . 123555567 0 0 44 20507 21319 26.842976 . . . 123555567 0 0 45 20507 21326 27.07438 . . . 123555567 0 0 46 20507 21340 27.53719 . . . 123555567 0 0 47 20507 21346 27.735537 . . . 123555567 0 0 48 20507 21347 27.768595 . . . 123555567 0 0 49 20507 21375 28.694216 . . 1 123555567 0 0 50 20507 21381 28.892563 . . 1 123555567 0 0 51 20507 21399 29.487604 . . 1 123555567 0 0 52 20507 21403 29.619835 . . 1 123555567 0 0 53 20507 21411 29.8843 . . 1 123555567 0 0 54 20507 21413 29.95041 . . 1 123555567 0 0 55 20507 21416 30.04959 . . 1 123555567 0 0 56 20507 21424 30.31405 . . 1 123555567 0 0 57 20507 21433 30.61157 . . 1 123555567 0 0 58 20507 21452 31.23967 . . 1 123555567 0 0 59 20507 21459 31.471075 . . 1 123555567 0 0 60 20507 21466 31.70248 . . 1 123555567 0 0 61 20507 21480 32.16529 . . . 123555567 0 0 62 20507 21493 32.595043 . . . 123555567 0 0 63 20507 21494 32.628098 . . . 123555567 0 0 64 20507 21501 32.859505 . . . 123555567 0 0 65 20507 21508 33.090908 . . . 123555567 0 0 66 20507 21515 33.322315 . . . 123555567 0 0 67 20507 21536 34.01653 . . . 123555567 0 0 68 20507 21544 34.28099 . . . 123555567 0 0 69 20507 21563 34.909092 . . . 123555567 0 0 70 20507 21628 37.05785 . . . 123555567 0 0 71 20507 21641 37.487602 . . . 123555567 0 0 72 20507 21648 37.71901 . . . 123555567 0 0 73 20507 21655 37.950413 . . . 123555567 0 0 74 20507 21662 38.18182 . . . 123555567 0 0 75 20507 21676 38.64463 . . . 123555567 0 0 76 20507 21683 38.87603 . . . 123555567 0 0 77 20507 21690 39.10744 . . . 123555567 0 0 78 20507 21697 39.33884 . . . 123555567 0 0 79 20507 21705 39.60331 . . . 123555567 0 0 80 20507 21725 40.26446 . . . 123555567 0 0 81 20507 21727 40.33058 . . . 123555567 0 0 82 20507 21732 40.49587 . . . 123555567 0 0 83 20507 21739 40.72727 . . . 123555567 0 0 84 20507 21760 41.42149 . . . 123555567 0 0 85 20507 21767 41.65289 . . . 123555567 0 0 86 20507 21774 41.8843 . . . 123555567 0 0 87 20507 21823 43.50413 . . . 123555567 0 0 88 20507 21830 43.73554 . . . 123555567 0 0 89 20507 21858 44.66116 . . . 123555567 0 0 90 20507 21865 44.89256 . . . 123555567 0 0 91 20507 21872 45.12397 . . . 123555567 0 0 92 20507 21878 45.32232 . . . 123555567 0 0 93 20507 21879 45.35537 . . . 123555567 0 0 94 20507 21886 45.58678 . . . 123555567 0 0 95 20507 21893 45.81818 . . . end format %td dataacomp_ca format %td dataacomp_en label values leite_peito_6m_2a_ca naosim label values hamburguer_6m_2a_ca naosim label def naosim 0 "nao", modify
