The script begins by creating a dataset named 'Headache' directly within the script using the `datalines` statement. This dataset contains variables for duration in minutes, treatment group, and a censoring indicator. After data creation, the script displays the first five observations of the 'Headache' dataset using PROC PRINT for a quick check. The main procedure is PROC LIFEREG, which is used to model survival data. It specifies 'Minutes' as the survival time variable, 'Censor' as the censoring status variable (where 1 indicates a censored event), and 'Group' as the explanatory classification variable. This procedure generates a new dataset 'New' which includes the cumulative distribution function (CDF) under the variable 'Prob'. Finally, PROC SGPLOT is employed to visualize the analysis results by generating a scatter plot. This plot represents 'Minutes' on the X-axis and 'Prob' (CDF) on the Y-axis, with data points grouped and colored according to the 'Group' variable, and a discrete legend is added for easier interpretation.
Data Analysis
Type : INTERNAL_CREATION
The 'Headache' dataset is created directly within the script using the `datalines` statement, providing data for survival analysis. The 'New' dataset is an intermediate result from PROC LIFEREG.
1 Code Block
DATA STEP Data
Explanation : This DATA STEP block creates a SAS dataset named 'Headache'. The variables 'Minutes', 'Group', and 'Censor' are defined. Data is read in-line via the `datalines` statement, simulating results from a clinical trial or study with observation times and censoring indicators.
Explanation : This block uses PROC PRINT to display the first five observations (rows) of the 'Headache' dataset. This is a common step to quickly verify the structure and content of the data after its creation or modification.
Copied!
proc print data=headache (obs=5);
run;
1
PROC PRINTDATA=headache (obs=5);
2
RUN;
3 Code Block
PROC LIFEREG Data
Explanation : This block executes PROC LIFEREG to perform an accelerated survival regression analysis on the 'Headache' dataset. The 'Group' variable is specified as a classification variable. The `model` statement defines the regression model, where 'Minutes' is the survival time variable, 'Censor' is the censoring status variable (with 1 indicating censoring, i.e., an unobserved event), and 'Group' is the explanatory variable. The `output` statement creates a new dataset 'New' that contains the original observations along with a new variable 'Prob' representing the estimated cumulative distribution function (CDF).
Copied!
proc lifereg data=Headache;
class Group;
model Minutes*Censor(1)=Group;
output out=New cdf=Prob;
run;
1
PROC LIFEREGDATA=Headache;
2
class Group;
3
model Minutes*Censor(1)=Group;
4
OUTPUT out=New cdf=Prob;
5
RUN;
4 Code Block
PROC SGPLOT
Explanation : This block uses PROC SGPLOT to generate a graphical visualization. It creates a scatter plot from the 'New' dataset created by PROC LIFEREG. 'Minutes' are represented on the X-axis and 'Prob' (CDF) values on the Y-axis. The `/ group=Group` option colors the data points according to the categories of the 'Group' variable, and `discretelegend` adds a discrete legend to identify these groups.
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.