I have a dataset in long format, measuring spirometry data on three occasions. I want to create a variable called "cycle", indicating which cycle 1-3 the measurement is taken from. How do I do it?
----------------------- copy starting from the next line -----------------------
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str13 PID_109925 double(FEV1NT FEV1PNT FVCNT) float(age_centered age_centered2) double height float height2 double gender float intercept "1099250000068" 4.21 97.8 5.21 21.2 449.44 180 32400 1 1 "1099250000068" 2.56 64.3 3.5 32.1 1030.4099 180.2 32472.04 1 1 "1099250000068" 3.18 87.719 4.45 42.2 1780.84 180.5 32580.25 1 1 "1099250000075" 3.55 115.5 4.24 12.2 148.84 160 25600 2 1 "1099250000075" 3.2 112.7 3.82 24.2 585.64 160.6 25792.36 2 1 "1099250000075" 3.16 125.042 3.85 34.5 1190.25 159 25281 2 1 "1099250000112" 1.69 84.8 2.59 54.2 2937.64 159 25281 2 1 "1099250000143" 4.37 90.8 5.34 9 81 183 33489 1 1 "1099250000280" 1.25 71 1.97 56.7 3214.89 152.4 23225.76 2 1 "1099250000303" 3.41 100.213 4.19 21 441 172.7 29825.29 2 1 "1099250000310" 3.73 93 6.13 26 676 177 31329 1 1 "1099250000358" 3.05 65.2 5.34 18 324 185 34225 1 1 "1099250000358" 2.8 64.3 5.09 28.7 823.6901 185.4 34373.16 1 1 "1099250000433" 2.92 89.5 3.78 8.3 68.89 163.2 26634.24 2 1 "1099250000433" 2.8 91.217 3.77 19.7 388.09 163.7 26797.69 2 1 "1099250000440" 5.99 118.5 7.2 8.9 79.20999 187 34969 1 1 "1099250000440" 5.57 117 6.43 19.9 396.01 187.6 35193.76 1 1 "1099250000440" 5.31 119.808 6.24 29.6 876.16 187.4 35118.76 1 1 "1099250000549" 1.94 74 2.3 19.7 388.09 152 23104 2 1 "1099250000556" 2.33 104.5 . 38.6 1489.96 153 23409 2 1 "1099250000556" 1.74 92.3 2.34 50.2 2520.04 151 22801 2 1 "1099250000556" 1.55 97.266 2.36 61.5 3782.25 149.8 22440.04 2 1 "1099250000594" 3.23 94 3.87 6.2 38.44 166.5 27722.25 2 1 "1099250000594" 3.23 98.176 3.95 16.4 268.96 167.2 27955.84 2 1 "1099250000631" 2.59 106.2 3.44 44.8 2007.04 165.1 27258.01 2 1 "1099250000747" 3.77 120.6 4.49 6.7 44.89 159.4 25408.36 2 1 "1099250000747" 2.69 89.832 3.4 16.7 278.89 160.1 25632.01 2 1 "1099250000808" 5.94 121.721 7.2 11.6 134.56001 185.4 34373.16 1 1 "1099250000815" 2.76 94 3.58 24 576 163 26569 2 1 "1099250000815" 1.81 77.891 2.71 45.9 2106.81 162.4 26373.76 2 1 "1099250000822" 3.37 103 4.47 45.3 2052.0898 175 30625 1 1 "1099250000822" 3.15 115 4.43 56.1 3147.21 170.6 29104.36 1 1 "1099250000839" 4.33 108.3 5.04 35.4 1253.16 182.9 33452.41 1 1 "1099250000839" 3.78 105.197 4.86 45.8 2097.64 183 33489 1 1 "1099250000853" 2.2 91.6 2.87 40.5 1640.25 160 25600 2 1 "1099250000877" 3.09 92.7 3.7 2.4 5.76 163 26569 2 1 "1099250000907" 2.32 109.6 2.7 55.2 3047.04 164.6 27093.16 2 1 "1099250000976" 2.17 98.05 3.15 49 2401 161.7 26146.89 2 1 "1099250001003" 2.48 80.9 3.91 30.5 930.25 171 29241 2 1 "1099250001027" 2.43 76.9 4.04 51.8 2683.24 178 31684 1 1 "1099250001027" 1.45 54.9 2.02 63.4 4019.56 173.8 30206.44 1 1 "1099250001072" 2.3 105.1 3 52.1 2714.41 164 26896 2 1 "1099250001072" 2.11 136.237 2.78 73.2 5358.24 158.1 24995.61 2 1 "1099250001102" 3.07 79.637 4.13 1.2 1.44 174.3 30380.49 2 1 "1099250001218" 3.51 98.69 4.96 16.3 265.68997 173.4 30067.56 2 1 "1099250001225" 2.09 88.9 2.32 45.6 2079.3599 163 26569 2 1 "1099250001287" 3.67 79.3 4.67 30.4 924.16 191.6 36710.56 1 1 "1099250001379" 2.23 103.322 2.91 48.9 2391.2102 159.7 25504.09 2 1 "1099250001430" 3.63 115.8 4.3 39.6 1568.16 167 27889 1 1 "1099250001430" 3.23 119.2 4.27 50.6 2560.36 165.1 27258.01 1 1 "1099250001478" 3.09 114.074 3.8 35.4 1253.16 . . 2 1 "1099250001546" 3.34 91.3 4.08 24.4 595.36 169 28561 1 1 "1099250001577" 2.61 70.2 4.45 34 1156 176 30976 1 1 "1099250001645" 2.03 70.7 3.01 20.4 416.16 159 25281 2 1 "1099250001645" 1.97 76.9 2.82 32 1024 158.2 25027.24 2 1 "1099250001645" 1.66 76.485 2.5 42.7 1823.29 154.4 23839.36 2 1 "1099250001690" 2.97 90.6 3.75 24.4 595.36 172 29584 2 1 "1099250001690" 2.98 102.2 3.53 35.4 1253.16 170.8 29172.64 2 1 "1099250001690" 2.38 92.038 2.98 44.9 2016.01 169.8 28832.04 2 1 "1099250001720" 3.67 95.6 5.25 43.1 1857.61 186 34596 1 1 "1099250001720" 3.48 104.5 4.98 54.2 2937.64 184.5 34040.25 1 1 "1099250001737" 4.11 72.1 5.85 6.3 39.69 196 38416 1 1 "1099250001751" 4.15 96.4 5.63 13.3 176.89 176 30976 1 1 "1099250001751" 4.02 99.5 5.46 23.8 566.43994 176.4 31116.96 1 1 "1099250001751" 3.9 104.694 5.36 34.9 1218.0101 176.8 31258.24 1 1 "1099250001874" 4.72 90.973 6.57 6.2 38.44 187.8 35268.84 1 1 "1099250001911" 3.87 85.342 5.49 20.4 416.16 183.8 33782.44 1 1 "1099250001959" 3.2 100.5 4.3 7.3 53.29 161 25921 2 1 "1099250001959" 2.96 98.4 3.96 17.4 302.75998 160.8 25856.64 2 1 "1099250001980" 1.34 74.693 2.33 54.6 2981.16 151.7 23012.89 2 1 "1099250001997" 5.4 117.008 6.22 11.4 129.95999 180.7 32652.49 1 1 "1099250002000" 5.75 119.7 7.01 17.8 316.84 187.2 35043.84 1 1 "1099250002000" 5.19 118.52 6.51 29 841 186 34596 1 1 "1099250002017" 4.05 91.43 5.12 4.6 21.16 174.2 30345.64 1 1 "1099250002031" 3.9 93.446 4.86 20.3 412.09 177 31329 1 1 "1099250002079" 2.4 92.813 3.1 20.6 424.36 151.5 22952.25 2 1 "1099250002086" 2 71.311 3.41 38.1 1451.61 170 28900 2 1 "1099250002147" .79 37 1.52 42.4 1797.76 153 23409 2 1 "1099250002154" 2.26 75.4 2.94 28.8 829.4399 168 28224 2 1 "1099250002154" 1.76 65.194 2.36 39.4 1552.36 168.1 28257.61 2 1 "1099250002161" 1.76 86.7 2.54 55.6 3091.36 161.8 26179.24 2 1 "1099250002185" 4.4 89.931 6.77 6.2 38.44 182.9 33452.41 1 1 "1099250002192" 2.04 109.8 . 57.4 3294.76 157 24649 2 1 "1099250002222" 1.26 51.785 2.82 39.8 1584.04 160.4 25728.16 2 1 "1099250002277" 3.51 91.3 4.58 34.4 1183.3601 179 32041 1 1 "1099250002307" 4.29 99.2 5.52 14.8 219.04 177 31329 1 1 "1099250002307" 4.01 100.4 5.09 26 676 176.7 31222.89 1 1 "1099250002307" 3.5 95.343 4.77 36.6 1339.56 176.9 31293.61 1 1 "1099250002406" 3.88 103.9 4.8 2.6 6.759999 172 29584 2 1 "1099250002420" 4.03 104.1 5.2 27.4 750.7599 175 30625 1 1 "1099250002420" 3.7 105.5 4.9 37.4 1398.76 173.9 30241.21 1 1 "1099250002437" 2.26 96.5 2.7 42.7 1823.29 160 25600 2 1 "1099250002444" 2.86 102.5 3.57 20.5 420.25 157 24649 2 1 "1099250002444" 2.43 97.2 3.03 32 1024 156.4 24460.96 2 1 "1099250002482" .96 49.9 1.72 51.8 2683.24 154 23716 2 1 "1099250002499" 4.54 99.3 5.19 5.4 29.16 177 31329 1 1 "1099250002499" 4.01 100.409 5.1 26.2 686.4401 176.8 31258.24 1 1 "1099250002512" 1.95 67.2 3.06 51.5 2652.25 171 29241 1 1 "1099250002536" 1.68 90.2 2.39 55.2 3047.04 155 24025 2 1 "1099250002604" 3.64 94.076 4.4 3.6 12.96 175.2 30695.04 2 1 end label values gender Sex_lbl label def Sex_lbl 1 "Man", modify label def Sex_lbl 2 "Woman", modify
0 Response to Create an indicator of participation in long format
Post a Comment