Hi All
I have 4 variables; cancer1, cancer2, cancer3 & cancer4, which show the year of diagnosis of cancer (for one up to 4 possible cancer diagnosis). A year of diagnosis indicates that a patient has had cancer, otherwise missing.
Based on the above 4 variables, I'd like to create 5 new variables (all binary, 0/1, where 1 indicates a cancer diagnosis):
cancer82 - which will indicate if a patient received a cancer diagnosis up to & including 1982
cancer89 - which will indicate if a patient received a cancer diagnosis between 1983 and 1989
cancer99 - which will indicate if a patient received a cancer diagnosis between 1990 and 1999
cancer09 - which will indicate if a patient received a cancer diagnosis between 2000 and 2009
cancer15 - which will indicate if a patient received a cancer diagnosis between 2010 and 2015
An example of the dataset is below:
id cancer1 cancer2 cancer3 cancer4
1 2000
2
3 2015
4
5
6 2011 2013
7 1988 2001
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 2009
29
30
31
32
33
34
35
36 1989
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51 2000
52 2004
53
54 1999
Any ideas how to go about the above using loops (to take care of any subject who might have had more than one diagnosis?
Many Thanks!
/Amal
I have 4 variables; cancer1, cancer2, cancer3 & cancer4, which show the year of diagnosis of cancer (for one up to 4 possible cancer diagnosis). A year of diagnosis indicates that a patient has had cancer, otherwise missing.
Based on the above 4 variables, I'd like to create 5 new variables (all binary, 0/1, where 1 indicates a cancer diagnosis):
cancer82 - which will indicate if a patient received a cancer diagnosis up to & including 1982
cancer89 - which will indicate if a patient received a cancer diagnosis between 1983 and 1989
cancer99 - which will indicate if a patient received a cancer diagnosis between 1990 and 1999
cancer09 - which will indicate if a patient received a cancer diagnosis between 2000 and 2009
cancer15 - which will indicate if a patient received a cancer diagnosis between 2010 and 2015
An example of the dataset is below:
id cancer1 cancer2 cancer3 cancer4
1 2000
2
3 2015
4
5
6 2011 2013
7 1988 2001
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 2009
29
30
31
32
33
34
35
36 1989
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51 2000
52 2004
53
54 1999
Any ideas how to go about the above using loops (to take care of any subject who might have had more than one diagnosis?
Many Thanks!
/Amal
Comment