The script begins by configuring the ODS (Output Delivery System) environment for graphic output. It then executes the LIFETEST procedure on the 'sashelp.BMT' dataset to perform a survival analysis stratified by the 'Group' variable. The survival plot data is captured in a dataset named 'SurvivalPlotData'. Subsequently, the SGPLOT procedure is used three times to generate different versions of a survival plot, varying the position and style of the subjects at risk table (outside or inside the plot) and the general ODS style.
Data Analysis
Type : SASHELP
The script exclusively uses the BMT dataset from the standard SASHELP library, which contains bone marrow transplant data.
1 Code Block
PROC LIFETEST Data
Explanation : This block initializes the graphical output environment and executes the LIFETEST procedure. Survival analysis is performed on sashelp.BMT data, using the T variable for time and Status for the event. The analysis is stratified by 'Group'. Graphical results, including survival curve points, are saved in the 'SurvivalPlotData' table using the 'ods output' statement.
Copied!
%let gpath='.';
%let dpi=300;
ods html close;
ods listing style=htmlblue image_dpi=&dpi gpath=&gpath;
ods graphics on;
ods output Survivalplot=SurvivalPlotData;
proc lifetest data=sashelp.BMT plots=survival(atrisk=0 to 2500 by 500);
time T * Status(0);
strata Group / test=logrank adjust=sidak;
run;
PROC LIFETESTDATA=sashelp.BMT plots=survival(atrisk=0 to 2500BY500);
9
time T * STATUS(0);
10
strata Group / test=logrank adjust=sidak;
11
RUN;
2 Code Block
PROC SGPLOT
Explanation : This block uses PROC SGPLOT to generate a survival curve (STEP statement) with markers for censored data (SCATTER statement). The main feature of this plot is the addition of a subjects at risk table (xaxistable) positioned outside, below the X-axis.
Explanation : Similar to the previous block, this code generates the same survival curve. The key difference is that the subjects at risk table (xaxistable) is configured with 'location=inside', which places it at the bottom of the plot, superimposed on the plotting area.
Explanation : This last block changes the ODS style to 'journal' and generates a third version of the plot. The subjects at risk table is still inside. Aesthetic options are added, such as labels directly on the curves (curvelabel) and a different marker style for censored data (filled circle).
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.