I have the following variables in my dataset: ID, group, nnid1, TRT, OUTCOME
- There are two groups (group 1 and group 4) in my dataset.
- IDs belonging to group 4 are often repeated more than once. IDs belonging to group 1 are always unique/ no repetition.
- Group 1 has TRT=1 and Group 4 has TRT=0.
- For each nnid in group 1 there is a corresponding nnid in group 4
delta for ID 11001 (& nnid 110) = 74121.6 - 33597
delta for ID 10876 (& nnid 110)= 26838 - 33597
delta for ID 11065 (& nnid 110)= 6540.8 - 33597
delta for ID 40024 (& nnid 110)= Not needed
delta for ID 40024 (& nnid 110)= Not needed
delta for ID 40024 (& nnid 110)= Not needed
delta for ID 10779 (& nnid 114) = 15594 - 2541.4
delta for ID 40039 (& nnid 114) = Not needed
Can anyone help me with how I get this?
Thank you in advance!
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float(ID group) double nnid1 byte TRT OUTCOME 11001 1 110 1 74121.6 10876 1 110 1 26838 11065 1 110 1 6540.801 40024 4 110 0 33597 40024 4 110 0 33597 40024 4 110 0 33597 10779 1 114 1 15594 40039 4 114 0 2541.4 10730 1 118 1 9377.6 10686 1 118 1 128499.8 40044 4 118 0 2171.4 40044 4 118 0 2171.4 11162 1 120 1 40292.3 10771 1 120 1 39623.7 40049 4 120 0 15602.8 40049 4 120 0 15602.8 30657 3 130 1 16016 30665 3 130 1 -1210.2998 40067 4 130 0 -2642.4 40067 4 130 0 -2642.4 10802 1 133 1 29697.4 10647 1 133 1 15374.7 10781 1 133 1 897.8011 40070 4 133 0 10237.2 40070 4 133 0 10237.2 40070 4 133 0 10237.2 11153 1 137 1 34854.4 31033 3 137 1 24182.8 40074 4 137 0 1303.2 40074 4 137 0 1303.2 10709 1 142 1 43377.7 10700 1 142 1 36478.6 40081 4 142 0 1841.4 40081 4 142 0 1841.4 10678 1 146 1 49583.2 40087 4 146 0 23243.5 11227 1 154 1 75483.4 40097 4 154 0 22294 30625 3 156 1 8705 40100 4 156 0 12651 11000 1 164 1 144686.5 10628 1 164 1 23597.8 40111 4 164 0 45972.2 40111 4 164 0 45972.2 11002 1 165 1 13886.4 40112 4 165 0 16287.2 11291 1 170 1 57868 40117 4 170 0 4972 30994 3 175 1 22285.6 40124 4 175 0 10096.6 11190 1 178 1 68518.8 40132 4 178 0 21611.1 11003 1 189 1 62155.6 11056 1 189 1 59075.5 40150 4 189 0 18291.1 40150 4 189 0 18291.1 30780 3 211 1 15477.6 31268 3 211 1 2286 30688 3 211 1 12066.4 30889 3 211 1 5088 40181 4 211 0 2311 40181 4 211 0 2311 40181 4 211 0 2311 40181 4 211 0 2311 30928 3 217 1 -3743.301 40190 4 217 0 16502.102 10969 1 218 1 23673.5 40191 4 218 0 6296.4 10627 1 225 1 -30023.8 11007 1 225 1 95695.3 10832 1 225 1 14873.4 40199 4 225 0 11302.8 40199 4 225 0 11302.8 40199 4 225 0 11302.8 11021 1 226 1 11827.6 40200 4 226 0 24130.5 10768 1 228 1 -13121.3 40204 4 228 0 12745 30873 3 230 1 12066.4 30682 3 230 1 21836.4 40207 4 230 0 7585.9 40207 4 230 0 7585.9 10805 1 240 1 40199.1 40221 4 240 0 3852.6 10798 1 241 1 35838.7 40227 4 241 0 28955.6 11207 1 249 1 50614.4 10609 1 249 1 30747.7 11040 1 249 1 50646.8 40235 4 249 0 444 40235 4 249 0 444 40235 4 249 0 444 30865 3 252 1 3177.6 40241 4 252 0 9105.5 10923 1 255 1 4611.301 40248 4 255 0 24272.3 30827 3 261 1 20121.8 40262 4 261 0 39448.9 11292 1 271 1 56628 40277 4 271 0 10801.6 end
0 Response to How to subtract within a column based on criteria from other columns?
Post a Comment