Function

Note
It is crucial to remember that before stcox can be performed, we need to stset our data. See Declare that the data are time-to-event data for more information and to stset the dataset so it is ready for the upcoming example. 

Basic command
stcox indepvars 
Useful options
stcox indepvars, noshow 
Explanations
indepvarsInsert the name of the x-variable(s) that you want to use.
irrProduces incidence rate ratios.
More information
help stcox 

Note
The dependent variable (y-variable) is already specified through stset. 

A walk-through of the output

When we perform a Cox regression in Stata, the table looks like this: 

In this example, xvar1 is a binary (0/1) variable and xvar2 is a continuous variable ranging between 100 and 500. 

The upper part of the table shows a model summary. This is what the different rows mean:

No. of subjects Number of subjects included in the model. 
No. of failures Number of cases (i.e. subjects that have experienced the event). 
Time at risk Total observational time, according to the specified unit (e.g. year). 
Log likelihood This value does not mean anything in itself, but can be used if we would like compare nested models. 
Number of obs The number of observations included in the model. 
LR chi2(x) The likelihood ratio (LR) chi-square test. The number within the brackets shows the degrees of freedom (one per variable). 
Prob >chi2 Shows the probability of obtaining the chi-square statistic given that there is no statistical effect of the x-variables on y. If the p-value is below 0.05, we can conclude that the overall model is statistically significant.    

The lower part of the table presents the parameter estimates from the analysis.

 The first column lists the predicted value of the y-variable on top (_t), followed by our x-variable(s). 
Haz. Ratio These are the hazard ratios. 
Std. Err. The standard errors associated with the coefficient. 
Z Z-value (coefficient divided by the standard error of the coefficient). 
P>|z| P-value. 
[95% Conf. Interval] 95% confidence intervals (lower limit and upper limit). 

The analytical sample used for the examples

In the subsequent sections, we will use the following variables:

Dataset
StataData1.dta
Variable namecvd
Variable labelOut-patient care due to CVD (Ages 41-50, Year 2011-2020)
Value labels0=No
1=Yes
Variable namegpa
Variable labelGrade point average (Age 15, Year 1985)
Value labelsN/A
Variable namesex
Variable labelSex
Value labels0=Man
1=Woman
Variable namemarstat40
Variable labelMarital status (Age 40, Year 2010)
Value labels1=Married
2=Unmarried
3=Divorced
4=Widowed

sum cvd gpa sex marstat40

We define our analytical sample through the following command:

gen pop_cox=1 if cvd!=. & gpa!=. & sex!=. & marstat40!=.

This means that new the variable pop_cox gets the value 1 if the four variables do not have missing information. In this case, we have 8,464 individuals that are included in our analytical sample.

tab pop_cox