I have a hospital record dataset with variables such as hospitalisation id (n_aih), year of hospitalisation (ano_ini), code of diagnosis (cid_pri), code of performed procedure (proc), and code of hospital (cnes) where the hospitalisation took place. Each row corresponds to a different hospitalisation. I would like to know not only how many hospitalisations there have been by diagnosis-year, but also how many different codes of procedures as well as how many different codes of hospitals there have been by diagnosis-year. My code below just inform me the former, but not the latter. Is there any stat I could use with the collapse command or any other way to get the information of number of different codes of procedures (and hospitals) for each diagnosis in each of the available years?

Code:
gen um=1
collapse (sum)num=um, by(cid_pri ano_ini)
Many thanks
Paula