**[ST] sts** -- Generate, graph, list, and test the survivor and cumulative
hazard functions

__Syntax__

**sts** [__g__**raph**] [*if*] [*in*] [**,** ...]

**sts** __l__**ist** [*if*] [*in*] [**,** ...]

**sts** __t__**est** *varlist* [*if*] [*in*] [**,** ...]

**sts** __gen__**erate** *newvar* **=** ... [*if*] [*in*] [**,** ...]

You must **stset** your data before using **sts**; see **[ST] stset**.
**fweight**s, **iweight**s, and **pweight**s may be specified using **stset**; see **[ST]**
**stset**.

See **[ST] sts graph**, **[ST] sts list**, **[ST] sts test**, and **[ST] sts generate**
for details of syntax.

__Description__

**sts** reports and creates variables containing the estimated survivor and
related functions, such as the Nelson-Aalen cumulative hazard function.
For the survivor function, **sts** tests and produces Kaplan-Meier estimates
or, via Cox regression, adjusted estimates.

**sts graph** is equivalent to typing **sts** by itself -- it graphs the
survivor function.

**sts list** lists the estimated survivor and related functions.

**sts test** tests the equality of the survivor function across groups.

**sts generate** creates new variables containing the estimated survivor
function, the Nelson-Aalen cumulative hazard function, or related
functions.

**sts** can be used with single- or multiple-record or single- or
multiple-failure st data.

__Example: Listing, graphing, and generating variables__

Setup
**. webuse stan3**

Suppress showing of st settings
**. stset, noshow**

List the survivor function
**. sts list**

Graph the survivor function
**. sts graph**

Create **survf** containing the survivor function
**. sts gen survf = s**

Sort on the time variable
**. sort t1**

List part of the data
**. list t1 survf in 1/10**

__Example: Comparing survivor or cumulative hazard functions__

Graph the survivor functions for the two categories of **posttran**, showing
results on one graph
**. sts graph, by(posttran)**

Graph the Nelson-Aalen cumulative hazard functions for the two categories
of **posttran**
**. sts graph, cumhaz by(posttran)**

List the survivor functions for the two categories of **posttran**, including
a number-who-enter column
**. sts list, by(posttran) enter**

List the two categories of **posttran** side by side for the survivor
function, selecting a subset of comparison times
**. sts list, by(posttran) compare**

List the two categories of **posttran** side by side for the cumulative
hazard function, selecting a subset of comparison times
**. sts list, cumhaz by(posttran) compare**

List the two categories of **posttran** side by side for the survivor
function, using the specified comparison times
**. sts list, by(posttran) compare at(0 100 to 1700)**

__Example: Testing equality of survivor functions__

Perform log-rank test for equality of survivor functions
**. sts test posttran**

Perform Wilcoxon test for equality of survivor functions
**. sts test posttran, wilcoxon**

__Example: Adjusted estimates__

Setup
**. webuse drug2, clear**

Suppress displaying of st settings
**. stset, noshow**

Describe survival-time data
**. stdescribe**

Show st settings
**. st**

Summarize **age** and **drug**
**. summarize age drug**

Graph the survivor functions for the two categories of **drug**
**. sts graph, by(drug)**

Create variable containing the difference in age from 50
**. generate age50 = age - 50**

Graph the survivor functions for the two categories of **drug** adjusting for
age by scaling to age 50
**. sts graph, by(drug) adjustfor(age50)**

List the information that **sts graph** just plotted, selecting a subset of
comparison times
**. sts list, by(drug) adjustfor(age50) compare**

Same as above, but adjust for age, not scaled to age 50
**. sts list, by(drug) adjustfor(age) compare**

Same as above, but constrain the effect of **age50** to be the same across
strata
**. sts list, by(drug) adjustfor(age50) compare**

__Example: Counting the number lost due to censoring__

List the survivor function
**. sts list**

Graph the survivor function, showing the number lost as small numbers on
the plot
**. sts graph, lost**

Setup
**. webuse stan3, clear**

Suppress showing of st settings
**. stset, noshow**

List the survivor functions for the two categories of **posttran**, including
a number-who-enter column
**. sts list, by(posttran) enter**

Same as above, but do not include the number-who-enter column
**. sts list, by(posttran)**

List the survivor function, including a number-who-enter column
**. sts list, enter**

List the survivor function, but do not include the number-who-enter
column
**. sts list**

__Video examples__

How to graph survival curves

How to calculate the Kaplan-Meier survivor and Nelson-Aalen cumulative
hazard functions

How to test the equality of survivor functions using nonparametric tests

__Stored results__

See **sts test** for stored results details.