I recently completed analysis of a large dataset to generate age and sex stratified incident counts with the person years count. From this I aim to calculate crude and standardised incident rates using the incident density method. For this I used Stata 15.

I have attached a small sample from the data, using 2019 as an example, to demonstrate the data I have generated and arranged in variable format for the next stage of the analysis.

2019 will also be the reference population used for the direct standardisation (with the assumption that each person contributes a whole person year). The full data set has the same data as the attached sample from 2000-2019 with the exception of the reference population which is 2019 only.

Whilst I understand the method of what I am trying to do I confess I have struggled getting the Stata coding to complete the Standardisation and Standardised Incidence Rate generation.

After completing some reading I stset Pyrs as the time/exposure variable before then using the the ir command using the incidence count to generate a crude incidence rate, for example: ir Incident_case Sex Pyrs, by (Year) level (95).

Stata returns a response stating that "no observations r(2000);". I believe this is due to the ir command being more appropriate used for binary outcomes as opposed to a count of binary outcomes but may be wrong in this view as I am new to Stata use.

I would be grateful for any advice on the coding required to generate the crude and age standardised incidence rate. If I have missed any key information out please feel free to ask.

Matthew