Hello Statlist, I need to calculate differences between avi_study_day by non-missing BAMid within each studyid. For example, for studyid=0, I like to generate a var=10 between BAMid=2 and BAMid=1, and then var=7 between BAMid=3 and BAMid=2. Thank you for helping this out!
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input int(studyid avi_study_day) BAMid 0 2 1 0 4 . 0 6 . 0 12 2 0 19 3 0 33 4 0 43 5 0 58 6 0 63 . 0 64 . 0 75 7 0 77 . 0 104 8 0 122 9 0 129 10 0 135 . 0 152 11 0 166 12 0 175 13 1 2 1 1 12 . 1 18 2 1 28 3 2 2 . 2 3 . 2 6 1 2 8 . 2 13 2 2 15 . 2 16 . 2 20 3 2 22 . 2 24 . 2 25 . 2 28 4 2 29 . 2 33 . 2 34 . 2 36 5 2 38 . 2 39 . 2 43 6 2 44 . 2 50 . 2 55 7 2 62 . 2 63 8 2 68 . 2 74 . 2 76 9 2 77 . 2 82 . 2 89 10 2 96 . 2 97 11 2 101 . 2 103 . 2 107 12 2 109 . 2 131 . 2 139 . 2 158 . 4 1 1 4 2 . 4 16 . 4 17 2 4 21 . 4 24 . 4 33 3 4 40 . 4 41 . 4 46 4 4 47 . 4 50 . 4 53 . 4 55 5 4 57 . 4 60 . 4 62 . 4 63 . 4 64 6 4 68 . 4 70 . 4 71 7 4 72 . 4 75 . 4 77 . 4 83 . 8 6 . 8 8 1 8 9 . 8 13 . 8 20 2 8 22 . 8 25 . 8 28 . 8 30 . 8 31 . 8 37 . 8 43 3 end
Comment