Simple Cox regression with a categorical (non-binary) x

Theoretical examples 

Example 1
In this example, we estimate the association between age (x) and hospitalization for attempted suicide (y) among individuals ages 18 to 45 over a five-year period. The failure event is hospitalization for attempted suicide (0=No event, 1=Event). Age is coded into three categories: 1=Ages 18-25, 2=Ages 26-35, and 3=Ages 36-45. Ages 36-45 is selected as the reference category (HR=1.00). For Ages 18-25, HR=3.77; for Ages 26-35, HR=1.08. This means that, compared to individuals ages 36-45, individuals ages 18-25 have a 3.77 times higher risk for hospitalization for attempted suicide, whereas individuals ages 26-35 have a 1.08 times higher risk for hospitalization compared to the reference category.  
Example 2
We are interested in the relationship between marital status (x) and death attributable to Covid-19 over a six-month period. The failure event is death due to Covid-19 (y) (0=No event, 1=Event). Marital status is coded in four categories: 1=Married (reference category), 2=Divorced, 3=Widowed, and 4=Never married. The HRs for divorced, widowed, and never married individuals are 1.56, 1.98, and 2.47, respectively. Relative to those who are married, divorced, widowed, and never-married individuals have a higher hazard of mortality from Covid-19.  

Practical example

Dataset
StataData1.dta
Variable namecvd
Variable labelOut-patient care due to CVD (Ages 41-50, Year 2011-2020)
Value labels0=No
1=Yes
Variable namemarstat40
Variable labelMarital status (Age 40, Year 2010)
Value labels1=Married
2=Unmarried
3=Divorced
4=Widowed

sum cvd marstat40 if pop_cox==1

stcox ib1.marstat40 if pop_cox==1, noshow

Kaplan-Meier curves

sts graph if pop_cox==1, survival noorigin ylabel(.90(0.02)1) xlabel(40(1)51) by(marstat40)

More information
help sts graph
sts test marstat40 if pop_cox==1, noshow
More information
help sts test