I am using SAS for survival analysis, but a problem is I have to enter the data 13 times if on day 5, 13 bees were dead, like below.
SAS understands as “censor=1” if a bee is dead on a particular day. Use “censor=0” if at the end of 30 days, you still have 5 bees alive (or if you moved out 5 bees for protein analysis on day 7, these bees did not die, but are removed from next day’s statistics).
input treatment day censor bee#;
control 5 1 1
control 5 1 2
control 5 1 3
control 5 1 4
control 5 1 5
control 5 1 6
control 5 1 7
control 5 1 8
control 5 1 9
control 5 1 10
control 5 1 11
control 5 1 12
control 5 1 13
I need to come up with a Loop input treatment so this can be done in one line.
after posting the question on a forum, then I suddenly figured it out myself. here is the code:
DATA survival; input treatment day dead censor;
Do bee=1 to dead;
output;
end;
DATALINES;
gfp 24 1 1
gfp 48 2 1
gfp 96 3 1
gfp 96 20 0
rpl8 24 5 1
rpl8 48 12 1
rpl8 96 25 1
rpl8 96 3 0
;
RUN;
proc print; run;
proc lifetest plot=(s) graphics;
time day*censor(0); strata treatment;
run;
Proc print produced the correct output:
Obs treatment day dead censor bee ‘ censor=1 when a bee is dead. censor=0 when that bee is still alive@the end of experiment.
1 gfp 24 1 1 1
2 gfp 48 2 1 1
3 gfp 48 2 1 2
4 gfp 96 3 1 1
5 gfp 96 3 1 2
6 gfp 96 3 1 3
7 gfp 96 20 0 1
8 gfp 96 20 0 2
9 gfp 96 20 0 3
10 gfp 96 20 0 4
11 gfp 96 20 0 5
12 gfp 96 20 0 6
13 gfp 96 20 0 7
14 gfp 96 20 0 8
15 gfp 96 20 0 9
16 gfp 96 20 0 10
17 gfp 96 20 0 11
18 gfp 96 20 0 12
19 gfp 96 20 0 13
20 gfp 96 20 0 14
21 gfp 96 20 0 15
22 gfp 96 20 0 16
23 gfp 96 20 0 17
24 gfp 96 20 0 18
25 gfp 96 20 0 19
26 gfp 96 20 0 20
27 rpl8 24 5 1 1
28 rpl8 24 5 1 2
29 rpl8 24 5 1 3
30 rpl8 24 5 1 4
31 rpl8 24 5 1 5
32 rpl8 48 12 1 1
33 rpl8 48 12 1 2
34 rpl8 48 12 1 3
35 rpl8 48 12 1 4
36 rpl8 48 12 1 5
37 rpl8 48 12 1 6
38 rpl8 48 12 1 7
39 rpl8 48 12 1 8
40 rpl8 48 12 1 9
41 rpl8 48 12 1 10
42 rpl8 48 12 1 11
43 rpl8 48 12 1 12
44 rpl8 96 25 1 1
45 rpl8 96 25 1 2
46 rpl8 96 25 1 3
47 rpl8 96 25 1 4
48 rpl8 96 25 1 5
49 rpl8 96 25 1 6
50 rpl8 96 25 1 7
51 rpl8 96 25 1 8
52 rpl8 96 25 1 9
53 rpl8 96 25 1 10
54 rpl8 96 25 1 11
55 rpl8 96 25 1 12
56 rpl8 96 25 1 13
57 rpl8 96 25 1 14
58 rpl8 96 25 1 15
59 rpl8 96 25 1 16
60 rpl8 96 25 1 17
61 rpl8 96 25 1 18
62 rpl8 96 25 1 19
63 rpl8 96 25 1 20
64 rpl8 96 25 1 21
65 rpl8 96 25 1 22
66 rpl8 96 25 1 23
67 rpl8 96 25 1 24
68 rpl8 96 25 1 25
69 rpl8 96 8 0 1
70 rpl8 96 8 0 2
71 rpl8 96 8 0 3
8 lines of data now becomes 71 lines…so I saved 8 times of labor.
The results are also correct:
Test of Equality over Strata
Test Chi-Square DF Chi-Square Pr
Log-Rank 28.3464 1 〈.0001
Wilcoxon 24.3984 1 〈.0001
-2Log(LR) 18.5757 1 〈.0001
Survival analysis can be used for tracking the mortality of two groups of animals, or their behaviors. For example, for homing studies, we can consider a bee “censused” (=1) if it come home and use its time of arrival as the event time.