The script begins by creating three distinct datasets ('control', 'rad', 'radbpa') using DATA blocks and datalines statements to integrate survival time and censoring data. Each dataset represents a different treatment group within a study. These three datasets are then combined into a single dataset named 'prob7_7'. Two indicator variables ('grp1', 'grp2') are created to facilitate the identification of the 'rad' and 'radbpa' groups in subsequent analyses. After a summary display of the combined data via PROC PRINT for verification, the core of the analysis is performed by PROC LIFETEST. This procedure is configured to estimate and compare survival functions (Kaplan-Meier by default) and hazard functions between the three groups ('trt') with a Bonferroni correction for multiple comparisons. It also generates survival and hazard plots for result visualization. Symbolization options are used to differentiate the appearance of curves in the plots.
Data Analysis
Type : CREATION_INTERNE
The data (`time`, `censor`, `trt`) is entirely created internally within the SAS script via DATA blocks and `datalines` statements. There is no dependency on external files or pre-existing SAS libraries for raw data acquisition, other than the data generated by the script itself.
1 Code Block
DATA STEP Data
Explanation : This DATA block creates a dataset named `control`. It uses the `datalines` statement to read the values of the `time` and `censor` variables. A `trt` variable is assigned the value 'control' to identify this as the untreated group. The syntax ` @code_sas_json/hsdua2304@gmail.com_SAS_Assignment_1.json` found in the original code on the `input` line has been removed as it is a syntax error and does not correspond to the `datalines` reading mechanism. The value 'controp' has been corrected to 'control' to ensure code consistency and executability.
Copied!
data control; /*create data set for untreated group*/
input time censor;
trt='control'; /*Correction de 'controp' en 'control' pour cohérence avec le commentaire*/
datalines;
20 1 21 1 23 1 24 1 24 1 26 1 26 1 27 1 28 1 30
;
1
DATA control; /*create data set for untreated group*/
2
INPUT time censor;
3
trt='control'; /*Correction de 'controp' en 'control' pour cohérence avec le commentaire*/
4
DATALINES;
5
20121123124124126126127128130
6
;
7
2 Code Block
DATA STEP Data
Explanation : This DATA block creates a dataset named `rad` for the radiation-treated group. Similar to the previous block, it reads `time` and `censor` data via `datalines` and assigns the value 'rad' to the `trt` variable. The syntax ` @code_sas_json/hsdua2304@gmail.com_SAS_Assignment_1.json` found in the original code on the `input` line has been removed as it is a syntax error and does not correspond to the `datalines` reading mechanism.
Copied!
data rad; /*create data set for the radiated group*/
input time censor;
trt='rad';
datalines;
26 1 28 1 29 1 29 1 30 1 30 1 31 1 31 1 32 1 35 0
;
1
DATA rad; /*create data set for the radiated group*/
2
INPUT time censor;
3
trt='rad';
4
DATALINES;
5
26128129129130130131131132135 0
6
;
7
3 Code Block
DATA STEP Data
Explanation : This DATA block creates a dataset named `radbpa` for the radiation and BPA-treated group. It reads `time` and `censor` data via `datalines` and assigns the value 'radbpa' to the `trt` variable. The syntax ` @code_sas_json/hsdua2304@gmail.com_SAS_Assignment_1.json` found in the original code on the `input` line has been removed as it is a syntax error and does not correspond to the `datalines` reading mechanism.
Copied!
data radbpa; /*Create data set for the raduated + BPA group*/
input time censor;
trt='radbpa';
datalines;
31 1 32 1 34 1 35 1 36 1 38 1 38 1 39 1 42 0 42 0
;
1
DATA radbpa; /*Create data set for the raduated + BPA group*/
2
INPUT time censor;
3
trt='radbpa';
4
DATALINES;
5
31132134135136138138139142 0 42 0
6
;
7
4 Code Block
DATA STEP Data
Explanation : This DATA block combines the three previously created datasets (`control`, `rad`, `radbpa`) into a new single dataset named `prob7_7`. It also creates two binary variables `grp1` (equals 1 if `trt` is 'rad', 0 otherwise) and `grp2` (equals 1 if `trt` is 'radbpa', 0 otherwise) to facilitate comparisons. The `title` and `title3` statements define titles for subsequent outputs, particularly for the `PROC PRINT` and `PROC LIFETEST` procedures.
Copied!
data prob7_7; set control rad radbpa; /*Combine all these three samples*/
grp1=(trt='rad');
grp2=(trt='radbpa');
title 'Problem 7_7, page 240 --Boron neutron capture therapy';
title3 'grp1=rad, grp2=radbpa';
;
1
DATA prob7_7; SET control rad radbpa; /*Combine all these three samples*/
2
grp1=(trt='rad');
3
grp2=(trt='radbpa');
4
title 'Problem 7_7, page 240 --Boron neutron capture therapy';
5
title3 'grp1=rad, grp2=radbpa';
6
;
5 Code Block
PROC PRINT
Explanation : This procedure displays the content of the last created or active dataset, which is `prob7_7` in this context. It is used for a quick inspection of the combined data and to verify the accuracy of the group merge.
Copied!
proc print;
1
PROC PRINT;
6 Code Block
PROC LIFETEST
Explanation : This procedure performs a survival analysis on the `prob7_7` dataset. `plots=(s,h)` and `graphics` generate plots of survival functions (S, Kaplan-Meier by default) and cumulative hazard functions (H). `time time*censor(0)` specifies that `time` is the time variable and `censor` is the event variable where 0 indicates a censored observation (the event did not occur). `strata trt/adjust=bon` requests a stratified analysis by the `trt` variable ('control', 'rad', 'radbpa' groups) and applies Bonferroni correction for multiple comparisons between strata to adjust p-values. The `symbol1`, `symbol2`, `symbol3` statements customize the appearance of the curves in the generated plots for better visual distinction of the groups.
Copied!
/*Compare three groups, plot the survival functions and hazard functions*/
proc lifetest data=prob7_7 plots=(s,h) graphics;
time time*censor(0);
strata trt/adjust=bon;
symbol1 v=none color=black line=1;
symbol2 v=none color=black line=2;
symbol3 v=none color=black line=3;
run;
1
/*Compare three groups, plot the survival functions and hazard functions*/
2
PROC LIFETESTDATA=prob7_7 plots=(s,h) graphics;
3
time time*censor(0);
4
strata trt/adjust=bon;
5
symbol1 v=none color=black line=1;
6
symbol2 v=none color=black line=2;
7
symbol3 v=none color=black line=3;
8
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.
Copyright Info : SAS Code for problem 7.7 from the manual 'Survival Analysis Techniques for Censored and Truncated Data'.
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.