Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Table and derived values from entries in the table


From   Garry Anderson <[email protected]>
To   <[email protected]>
Subject   st: Table and derived values from entries in the table
Date   Thu, 17 Mar 2011 18:40:01 +1100

Dear Listers

I am enquiring how to include a value in a -table- that is a function of
two other values in the table.

An example follows in the -table- command. I wish to report in the third
row of a cell the value in the first row of the cell divided by the
value in the second row of the cell. For example, 2/18790 and 32/52407,
etc. Please note I am using individual data rather than summed data,
hence my use of the word sum in the contents list rather than mean.

. use http://www.stata-press.com/data/r11/dollhill3, clear

. list

     +-----------------------------------+
     | agecat   smokes   deaths   pyears |
     |-----------------------------------|
  1. |      1        1       32   52,407 |
  2. |      2        1      104   43,248 |
  3. |      3        1      206   28,612 |
  4. |      4        1      186   12,663 |
  5. |      5        1      102    5,317 |
     |-----------------------------------|
  6. |      1        0        2   18,790 |
  7. |      2        0       12   10,673 |
  8. |      3        0       28    5,710 |
  9. |      4        0       28    2,585 |
 10. |      5        0       31    1,462 |
     +-----------------------------------+

. table  agecat smokes,con(sum deaths sum pyears) col row

----------------------------------
          |         smokes        
   agecat |      0       1   Total
----------+-----------------------
        1 |      2      32      34
          |  18790   52407   71197
          | 
        2 |     12     104     116
          |  10673   43248   53921
          | 
        3 |     28     206     234
          |   5710   28612   34322
          | 
        4 |     28     186     214
          |   2585   12663   15248
          | 
        5 |     31     102     133
          |   1462    5317    6779
          | 
    Total |    101     630     731
          |  39220  142247  181467
----------------------------------

Kind regards, Garry
Garry Anderson
School of Veterinary Science
University of Melbourne
250 Princes Highway    Ph  03 9731 2221
WERRIBEE    3030       Fax 03 9731 2388
Email:  [email protected]

 


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index