Hello,
I wanted to start off with a disclaimer that I can't post an example of my data with dataex because my Stata is on a server that purposely does not support installing new commands.
I however made this table to try and describe it!
All the observations have a unique ID. The respective case ID just associates the controls with their respective cases. I made the matchgroup variable because the real ID numbers in the data are really long (like 15 characters) so having a matchgroup number ranging from 1 to around 2000 was much easier.
Essentially what I'm trying to do is fill in all the missing values for timing of exposure for the controls so that they share the value with their respective cases.
So I basically want Table A to turn into Table B.
TABLE A
TABLE B
Is there a command I can use to do this?
Thank you,
Jon
I wanted to start off with a disclaimer that I can't post an example of my data with dataex because my Stata is on a server that purposely does not support installing new commands.
I however made this table to try and describe it!
All the observations have a unique ID. The respective case ID just associates the controls with their respective cases. I made the matchgroup variable because the real ID numbers in the data are really long (like 15 characters) so having a matchgroup number ranging from 1 to around 2000 was much easier.
Essentially what I'm trying to do is fill in all the missing values for timing of exposure for the controls so that they share the value with their respective cases.
So I basically want Table A to turn into Table B.
TABLE A
ID | Respective Case ID | subject_type | matchgroup | timing of exposure |
42 | 42 | case | 1 | 4 |
43 | 42 | control | 1 | - |
44 | 42 | control | 1 | - |
45 | 45 | case | 2 | 11 |
46 | 45 | control | 2 | - |
47 | 45 | control | 2 | - |
48 | 48 | case | 3 | 1 |
49 | 48 | control | 3 | - |
50 | 48 | control | 3 | - |
51 | 51 | case | 4 | 20 |
52 | 51 | control | 4 | - |
53 | 51 | control | 4 | - |
TABLE B
ID | Respective Case ID | subject_type | matchgroup | timing of exposure |
42 | 42 | case | 1 | 4 |
43 | 42 | control | 1 | 4 |
44 | 42 | control | 1 | 4 |
45 | 45 | case | 2 | 11 |
46 | 45 | control | 2 | 11 |
47 | 45 | control | 2 | 11 |
48 | 48 | case | 3 | 1 |
49 | 48 | control | 3 | 1 |
50 | 48 | control | 3 | 1 |
51 | 51 | case | 4 | 20 |
52 | 51 | control | 4 | 20 |
53 | 51 | control | 4 | 20 |
Is there a command I can use to do this?
Thank you,
Jon
Comment