Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

[no subject]



-------------------------------------------------
-fillin- is useful for your problem:
 
clear
input id class5 number
1 2 12
1 3 6
1 4 2
2 1 3
2 2 1
2 5 8
end
 
fillin id class5
recode number(.=0)
drop _fillin
by id, sort: egen t=total(number)
gen proportion=number/t
 
list
     +--------------------------------------+
     | id   class5   number    t   propor~n |
     |--------------------------------------|
  1. |  1        1        0   20          0 |
  2. |  1        2       12   20         .6 |
  3. |  1        3        6   20         .3 |
  4. |  1        4        2   20         .1 |
  5. |  1        5        0   20          0 |
     |--------------------------------------|
  6. |  2        1        3   12        .25 |
  7. |  2        2        1   12   .0833333 |
  8. |  2        3        0   12          0 |
  9. |  2        4        0   12          0 |
 10. |  2        5        8   12   .6666667 |
     +--------------------------------------+
 
Hope this helps
Svend
 
________________________________________________________ 
 
Svend Juul
Institut for Folkesundhed, Afdeling for Epidemiologi
(Institute of Public Health, Department of Epidemiology)
Vennelyst Boulevard 6 
DK-8000 Aarhus C,  Denmark 
Phone, work:  +45 8942 6090 
Phone, home:  +45 8693 7796 
Fax:          +45 8613 1580 
E-mail:       [email protected] 
_________________________________________________________ 

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index