Hello,

I have individual-level survival data for a cohort of people with my exposure variable of interest coded 0-3. I would like to calculate SMR for exposure groups 1-3 using exposure = 0 as the reference group. I've therefore saved the age group-specific mortality rates in a separate file, sorted by age group.

I can't share the data itself due to confidentiality restrictions but here is an example of what it looks like (simplifying to 3 age groups):

Code:
clear
input byte exposure float(age_group failure persontime id)
0 1 0  15  1
0 1 0  15  2
0 1 0   7  3
0 1 1   3  4
0 1 1 2.5  5
0 2 0   5  6
0 2 0  15  7
0 2 0  15  8
0 2 0  11  9
0 2 1   5 10
0 2 1   4 11
0 2 1 2.2 12
0 3 0 3.2 13
0 3 0  15 14
0 3 0  15 15
0 3 0   7 16
0 3 1 3.2 17
0 3 1 9.4 18
0 3 1  14 19
1 1 0  15 20
1 1 0  15 21
1 1 0   8 22
1 1 1   3 23
1 2 0   9 24
1 2 0  15 25
1 2 0  15 26
1 2 0   4 27
1 2 1  12 28
1 2 1  .5 29
1 3 0   6 30
1 3 0  15 31
1 3 0  15 32
1 3 1   8 33
1 3 1   2 34
1 3 1   4 35
2 1 0  15 36
2 1 0  14 37
2 1 0   8 38
2 1 1   6 39
2 2 0  13 40
2 2 0  15 41
2 2 0   8 42
2 2 0   5 43
2 2 1   1 44
2 2 1  15 45
2 3 0   9 46
2 3 0  15 47
2 3 0  15 48
2 3 1   9 49
2 3 1   6 50
2 3 1   1 51
3 1 0  13 52
3 1 0  10 53
3 1 1   3 54
3 1 1   7 55
3 2 0  15 56
3 2 0  15 57
3 2 0   9 58
3 2 1 6.3 59
3 2 1   7 60
3 2 1   1 61
3 3 0  14 62
3 3 0  15 63
3 3 0  12 64
3 3 0   8 65
3 3 1  11 66
3 3 1  12 67
end


When I try to run stptime with the SMR option, I get the following error message:
"using data not sorted"

Code:
stptime, smr(age_group rate) using("U:\working\unexposed_rates.dta" by(exposure) per(100000)
This is despite the using data definitely being sorted. I also get the same message if I try

Code:
stptime if exposure>0, smr(age_group rate) using("U:\working\unexposed_rates.dta" by(exposure) per(100000)
I read this response that suggests that sorting the using data manually would fix the problem, but that hasn't been the case on my attempts: https://www.statalist.org/forums/for...-using-stptime

Any suggestions as to where I might be going wrong gratefully received.

Thanks