The script uses the 'Sashelp.BMT' (Bone Marrow Transplant) dataset to perform survival analyses. It demonstrates how to display the table of subjects at risk below the survival plot, perform Log-rank tests with Sidak adjustment for multiple comparisons, and compare groups to a specific control group. It also shows how to use PROC FORMAT and a DATA step to reclassify strata in a specific (non-alphabetic) order for graphs, and how to add Hall-Wellner confidence bands.
Data Analysis
Type : SASHELP
The script uses the standard 'Sashelp.BMT' table. A temporary derived table 'Bmt2' is created to illustrate the manipulation of strata order via formats.
1 Code Block
PROC PRINT
Explanation : Displays the first 10 observations of the Sashelp.BMT table for a data overview.
Copied!
proc print data=Sashelp.BMT(obs=10);
run;
1
PROC PRINTDATA=Sashelp.BMT(obs=10);
2
RUN;
2 Code Block
PROC LIFETEST
Explanation : Activates ODS Graphics. Performs a Kaplan-Meier survival analysis. The 'plots=survival(atrisk=...)' option displays the number of subjects at risk at specific intervals (every 500 days) below the graph. The 'adjust=sidak' option applies a Sidak adjustment to the Log-rank test p-values for multiple comparisons between groups.
Copied!
ods graphics on;
proc lifetest data=sashelp.BMT plots=survival(atrisk=0 to 2500 by 500);
time T * Status(0);
strata Group / test=logrank adjust=sidak;
run;
1
ods graphics on;
2
3
PROC LIFETESTDATA=sashelp.BMT plots=survival(atrisk=0 to 2500BY500);
4
time T * STATUS(0);
5
strata Group / test=logrank adjust=sidak;
6
RUN;
3 Code Block
PROC LIFETEST
Explanation : Performs a comparative analysis without producing graphs ('plots=none'). The 'diff=control' option compares all other groups to the specified control group ('AML-Low Risk') with Sidak adjustment.
Copied!
proc lifetest data=sashelp.BMT notable plots=none;
time T * Status(0);
strata Group / test=logrank adjust=sidak diff=control('AML-Low Risk');
run;
1
PROC LIFETESTDATA=sashelp.BMT notable plots=none;
2
time T * STATUS(0);
3
strata Group / test=logrank adjust=sidak diff=control('AML-Low Risk');
4
RUN;
4 Code Block
PROC FORMAT
Explanation : Creates an informat '$bmtifmt' to convert group character strings to numbers, and a format 'bmtfmt' to display these numbers as labels. This allows defining a custom sorting order.
Explanation : Creates a new table 'Bmt2' based on 'Sashelp.BMT'. The 'Group' variable is recreated numerically using the previously defined informat, forcing the internal order: 1=ALL, 2=Low Risk, 3=High Risk.
Copied!
data Bmt2;
set sashelp.BMT(rename=(Group=G));
Group = input(input(G, $bmtifmt.), 1.);
label Group = 'Disease Group';
format Group bmtfmt.;
run;
1
DATA Bmt2;
2
SET sashelp.BMT(rename=(Group=G));
3
Group = INPUT(INPUT(G, $bmtifmt.), 1.);
4
label Group = 'Disease Group';
5
FORMAT Group bmtfmt.;
6
RUN;
6 Code Block
PROC LIFETEST
Explanation : Performs the analysis on the sorted table 'Bmt2'. The 'order=internal' option uses the underlying numeric values (1, 2, 3) for the order of legends and curves, rather than alphabetical order. The 'atrisk(outside maxlen=13)' option places the table of subjects at risk outside the plot area and limits label length.
Copied!
proc LIFETEST data=Bmt2 plots=s(atrisk(outside maxlen=13)=0 to 2500 by 500);
time T*Status(0);
strata Group / order=internal;
run;
1
PROC LIFETESTDATA=Bmt2 plots=s(atrisk(outside maxlen=13)=0 to 2500BY500);
2
time T*STATUS(0);
3
strata Group / order=internal;
4
RUN;
7 Code Block
PROC LIFETEST
Explanation : Generates survival curves in separate panels ('strata=panel'). Adds pointwise confidence limits ('cl') and Hall-Wellner confidence bands ('cb=hw'). Deactivates ODS Graphics at the end.
Copied!
proc lifetest data=Bmt2 plots=survival(cl cb=hw strata=panel);
time T * Status(0);
strata Group/order=internal;
run;
ods graphics off;
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.
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.