The script begins by creating an internal dataset named 'Males'. This dataset is populated with raw data (datalines) that describe the number of failures and withdrawals per time period. The data is transformed to create individual observations with a censoring indicator (0 for events, 1 for censored cases) and a frequency variable. Then, the PROC LIFETEST procedure is used to analyze this survival data. It applies the life table method ('method=lt'), defines specific time intervals for the analysis, and generates a series of graphical plots (survival functions, log-survival, log-log survival, cumulative hazard, probability density) via the 'plots' option.
Data Analysis
Type : CREATION_INTERNE
The 'Males' dataset is created and populated directly in the script using a DATA STEP block and raw data specified via the DATALINES statement. The variables 'Freq', 'Years', and 'Censored' are constructed from this raw data.
1 Code Block
DATA STEP Data
Explanation : This DATA STEP block creates and populates the 'Males' dataset. It reads the number of failures ('fail') and withdrawals ('withdraw') from the provided datalines. For each 'fail'/'withdraw' pair, two observations are generated: one for events (Censored=0) with 'Freq' equal to 'fail', and another for censored cases (Censored=1) with 'Freq' equal to 'withdraw'. The 'Years' variable is incremented to define the follow-up periods. The 'Years' variable is initialized to -0.5 so that the next increment starts at 0.5.
Copied!
title 'Survival of Males with Angina Pectoris';
data Males;
keep Freq Years Censored;
retain Years -.5;
input fail withdraw;
Years + 1;
Censored=0;
Freq=fail;
output;
Censored=1;
Freq=withdraw;
output;
datalines;
456 0 226 39 152 22 171 23 135 24 125 107
83 133 74 102 51 68 42 64 43 45 34 53
18 33 9 27 6 23 0 30
;
1
title 'Survival of Males with Angina Pectoris';
2
DATA Males;
3
keep Freq Years Censored;
4
retain Years -.5;
5
INPUT fail withdraw;
6
Years + 1;
7
Censored=0;
8
Freq=fail;
9
OUTPUT;
10
Censored=1;
11
Freq=withdraw;
12
OUTPUT;
13
DATALINES;
14
456 0 22639152221712313524125107
15
83133741025168426443453453
16
1833927623 0 30
17
;
2 Code Block
PROC LIFETEST
Explanation : This PROC LIFETEST procedure performs the survival analysis. It uses the 'Males' dataset. The 'method=lt' option specifies the life table method. The 'intervals' are defined from 0 to 15 with a step of 1. The 'time Years*Censored(1)' statement designates 'Years' as the time variable and 'Censored' as the status variable, where '1' indicates a survival event (non-censored). 'freq Freq' indicates that the 'Freq' variable contains the frequencies of observations. The 'plots' option generates several types of survival plots. The ODS GRAPHICS commands activate and deactivate graphical output.
Copied!
ods graphics on;
proc lifetest data=Males method=lt intervals=(0 to 15 by 1)
plots=(s,ls,lls,h,p);
time Years*Censored(1);
freq Freq;
run;
ods graphics off;
1
ods graphics on;
2
PROC LIFETESTDATA=Males method=lt intervals=(0 to 15BY1)
3
plots=(s,ls,lls,h,p);
4
time Years*Censored(1);
5
freq Freq;
6
RUN;
7
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.
Copyright Info : S A S S A M P L E L I B R A R Y (NAME: LIFTEX3, PRODUCT: STAT)
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.