Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: posting question.


From   [email protected]
To   [email protected]
Subject   st: posting question.
Date   Thu, 30 Sep 2004 10:11:31 -0400

Hi,

The program mrate, from Macro International, computes mortality rates and save
them in global
macros. The under-five mortality rate for example is saved in $U_1_1.
I want to use a DHS survey tdataset and compute mortality rates in each cluster.


use benin

g id= _n

The cluster variable is v001:

l  v001 in 1/15

     +------+
      | v001 |
      |------|
  1. |    1 |
  2. |    1 |
  3. |    1 |
  4. |    1 |
  5. |    1 |
      |------|
  6. |    1 |
  7. |    1 |
  8. |    1 |
  9. |    1 |
 10. |    2 |
       |------|
 11. |    2 |
 12. |    2 |
 13. |    2 |
 14. |    2 |
 15. |    2 |
     +------+

su v001
    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
        v001 |      5953    130.4614     54.7308          1        210

postfile mortrate v001 double mortrate using mortrate , replace

su v001,meanonly
local nclust = r(max)
g mortrate = .
forval i=1/`nclust' {
    cap mrate if v001==`i'
    replace mortrate = $U_1_1
    post mortrate (v001) (mortrate)
}
postclose mortrate

use mortrate, clear

l in 1/15

     +------------------+
     | v001    mortrate |
     |------------------|
  1. |    1   111.11111 |
  2. |    1   333.33334 |
  3. |    1         500 |
  4. |    1   54.054054 |
  5. |    1           . |
     |------------------|
  6. |    1   111.11111 |
  7. |    1           . |
  8. |    1           . |
  9. |    1           . |
 10. |    1           . |
     |------------------|
 11. |    1         100 |
 12. |    1           . |
 13. |    1   133.33333 |
 14. |    1           . |
 15. |    1   133.33333 |
     +------------------+

How to get the correct values of v001 so that I can merge mortrate.dta with the
master benin.dta?

Thanks very much.

*
*   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