Hello,
I have a data set about suicide, suicide attempts and self-harm incidents for each prison in a country in 2023. I would like to calculate the suicide, suicide attempt and self-harm rates per prison (i.e., 3 rates for each prison). There are 76 prisons and the relevant variables are prison, incidenttype (suicide, suicide attempt or self-harm) and population (the numerical population on the day of the incident). The new variables (x_rate) should = number of x incidents / average population. This should be generated for each prison. So the 1st variable would be suicide_rate = number of suicides for each prison / average population for each prison. The 2nd variable would be Sattempt_rate and the 3rd SH_rate.
The first challenge is that the population changes by day so the population variable is not static per prison. I wish to use the average population per prison as the denominator. I calculated that as follows:
. mean population, over(prison)
I thought I would first generate a variable that can act as the denominator: gen Avpop = mean population, over(prison)but I got the message 'mean not found'.
The second challenge is that the data set includes all three types of incidents (suicides, attempts and self-harm in the variable incidenttype). So I am not sure how to generate the numerator for each of the new variables.
Thank you so much!
Maha
I have a data set about suicide, suicide attempts and self-harm incidents for each prison in a country in 2023. I would like to calculate the suicide, suicide attempt and self-harm rates per prison (i.e., 3 rates for each prison). There are 76 prisons and the relevant variables are prison, incidenttype (suicide, suicide attempt or self-harm) and population (the numerical population on the day of the incident). The new variables (x_rate) should = number of x incidents / average population. This should be generated for each prison. So the 1st variable would be suicide_rate = number of suicides for each prison / average population for each prison. The 2nd variable would be Sattempt_rate and the 3rd SH_rate.
The first challenge is that the population changes by day so the population variable is not static per prison. I wish to use the average population per prison as the denominator. I calculated that as follows:
. mean population, over(prison)
I thought I would first generate a variable that can act as the denominator: gen Avpop = mean population, over(prison)but I got the message 'mean not found'.
The second challenge is that the data set includes all three types of incidents (suicides, attempts and self-harm in the variable incidenttype). So I am not sure how to generate the numerator for each of the new variables.
Thank you so much!
Maha
Comment