This script creates an internal dataset ('exposed') containing survival times, censoring statuses, and covariates (Treatment, Sex). It then performs several survival analyses: estimation of survival functions (Kaplan-Meier), tests of equality between groups (Log-Rank), and stratifications, all while using ODS Graphics to visualize the survival curves.
Data Analysis
Type : CREATION_INTERNE
Data is created directly within the script via a DATA step with the DATALINES statement.
1 Code Block
PROC FORMAT
Explanation : Definition of a user-defined format to display 'Drug X' and 'Placebo' labels instead of numerical codes.
Copied!
proc format;
value Rx 1='Drug X' 0='Placebo';
run;
1
2
PROC FORMAT;
3
value Rx 1='Drug X' 0='Placebo';
4
RUN;
5
2 Code Block
DATA STEP Data
Explanation : Creation of the 'exposed' dataset containing the variables Days, Status, Treatment, and Sex. Usage of the @code_sas_json/8_SAS_Intro_ReadFile_MultiCol_@@.json instruction to read multiple observations per data line.
Copied!
data exposed;
input Days Status Treatment Sex $ @code_sas_json/8_SAS_Intro_ReadFile_MultiCol_@@.json;
format Treatment Rx.;
datalines;
179 1 1 F 378 0 1 M
256 1 1 F 355 1 1 M
262 1 1 M 319 1 1 M
256 1 1 F 256 1 1 M
255 1 1 M 171 1 1 F
224 0 1 F 325 1 1 M
225 1 1 F 325 1 1 M
287 1 1 M 217 1 1 F
319 1 1 M 255 1 1 F
264 1 1 M 256 1 1 F
237 0 0 F 291 1 0 M
156 1 0 F 323 1 0 M
270 1 0 M 253 1 0 M
257 1 0 M 206 1 0 F
242 1 0 M 206 1 0 F
157 1 0 F 237 1 0 M
249 1 0 M 211 1 0 F
180 1 0 F 229 1 0 F
226 1 0 F 234 1 0 F
268 0 0 M 209 1 0 F
;
1
DATA exposed;
2
INPUT Days STATUS Treatment Sex $ @code_sas_json/8_SAS_Intro_ReadFile_MultiCol_@@.json;
3
FORMAT Treatment Rx.;
4
DATALINES;
5
17911 F 378 0 1 M
6
25611 F 35511 M
7
26211 M 31911 M
8
25611 F 25611 M
9
25511 M 17111 F
10
224 0 1 F 32511 M
11
22511 F 32511 M
12
28711 M 21711 F
13
31911 M 25511 F
14
26411 M 25611 F
15
237 0 0 F 2911 0 M
16
1561 0 F 3231 0 M
17
2701 0 M 2531 0 M
18
2571 0 M 2061 0 F
19
2421 0 M 2061 0 F
20
1571 0 F 2371 0 M
21
2491 0 M 2111 0 F
22
1801 0 F 2291 0 F
23
2261 0 F 2341 0 F
24
268 0 0 M 2091 0 F
25
;
3 Code Block
PROC LIFETEST
Explanation : Execution of survival analysis stratified by Treatment. Activation of ODS Graphics to produce survival curves with a table of subjects at risk and a log-survival curve.
Explanation : Analysis stratified by Sex, comparing Treatment groups within each stratum. The 'notable' option suppresses the display of detailed survival tables.
Copied!
proc lifetest data=Exposed notable;
time Days*Status(0);
strata Sex / group=Treatment;
run;
1
PROC LIFETESTDATA=Exposed notable;
2
time Days*STATUS(0);
3
strata Sex / group=Treatment;
4
RUN;
5 Code Block
PROC LIFETEST
Explanation : Global test of the Treatment effect on survival (Log-Rank and Wilcoxon tests by default for two groups).
Copied!
proc lifetest data=Exposed notable;
time Days*Status(0);
test Treatment;
run;
1
PROC LIFETESTDATA=Exposed notable;
2
time Days*STATUS(0);
3
test Treatment;
4
RUN;
6 Code Block
PROC LIFETEST
Explanation : Test of the Treatment effect adjusted for Sex (by stratifying by Sex). The 'test=none' option in strata prevents the homogeneity test between strata (Sex).
Copied!
proc lifetest data=Exposed notable;
time Days*Status(0);
strata Sex / test=none;
test Treatment;
run;
1
PROC LIFETESTDATA=Exposed notable;
2
time Days*STATUS(0);
3
strata Sex / test=none;
4
test Treatment;
5
RUN;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
« Survival analysis is unique because it must account for censoring—the "Status" variable that indicates if an event actually occurred or if the subject simply left the study before the event happened. PROC LIFETEST is the primary tool for non-parametric estimation, specifically using the Kaplan-Meier method. »
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.