I have a dataset with 3 variables: (survival status "survived/died", year, number of observations). Now I would like to create a new variable which is basically the sum of the observations per year whilst ignoring the survival status. The reason I am trying to do this is because I would like to estimate the percentage later on based on the survival status (i.e. by dividing the number of observations per survival status by the total number of observations per year). I tried this command:
Code:
by year: gen tot = sum(num)
Any suggestions? Cheers!
0 Response to How to generate a variable with the total number per year only?
Post a Comment