Statalist


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

Re: st: RE: [9.2] mkmat rownames


From   Keith Dear <[email protected]>
To   [email protected]
Subject   Re: st: RE: [9.2] mkmat rownames
Date   Mon, 11 Feb 2008 08:11:18 +1100

Thanks Nick, but that option must be new in Stata 10.
Stata 9 has a -matname- command and also -matrix rownames-,
but both need an explicit <namelist>, not a variable name.
Ah well, one more reason to upgrade.
Keith

At 04:40 AM 11/02/2008, you wrote:
On the face of it, you should use the -rownames()- option to read in
your desired  row names. -mkmat- expects numeric variables to define the
(numeric) content of the matrix. At least that is the case in Stata 10.
At this moment I don't have access to Stata 9 or a manual for 9.

Nick
[email protected]

Keith Dear

I have a dataset that contains, in part:
. list tapm min max in 1/15

      +-----------------------------+
      |  tapm        min        max |
      |-----------------------------|
   1. |  tavg   9.281472   33.19886 |
   2. |  tmax   14.53456   41.24549 |
   3. |  tmin   .6966457   27.99766 |
   4. |  havg   1.905087   19.26358 |
   5. |  hmax   2.254643   23.64934 |
      |-----------------------------|
   6. |  ravg   18.82322   95.66055 |
   7. |  rmax   29.75645        100 |
   8. |    ws   .8907141   11.97882 |
   9. |  oavg   1.705984     52.421 |
  10. |  omax   5.090116    133.497 |
      |-----------------------------|
  11. |  navg   .0532477   25.27975 |
  12. |  nmax   .1555686   81.82613 |
  13. |  pavg   1.754097   39.62774 |
  14. |  pmax   2.989739   136.7765 |
  15. | o4max   3.433426   115.7704 |
      +-----------------------------+

I want to save the (min, max) values in a 15x2 matrix with rownames
from variable tapm.

This doesn't work:
. mkmat tapm min max in 1/15, mat(R)
varlist:  tapm:  string variable not allowed
r(109);

I can get the numbers in ok:
. mkmat min max in 1/15, mat(R)
. mat list R

R[15,2]
            min        max
  r1  9.2814722   33.19886
  r2  14.534559  41.245491
  r3  .69664574  27.997656
  r4  1.9050874   19.26358
  r5  2.2546427  23.649343
  r6  18.823215  95.660553
  r7  29.756449        100
  r8  .89071411  11.978825
  r9  1.7059844  52.421001
r10   5.090116  133.49698
r11  .05324766  25.279753
r12   .1555686  81.826134
r13  1.7540972  39.627739
r14  2.9897394  136.77647
r15  3.4334259  115.77041

But how do I get the names in? Not like this, for example:
. mat rownames R = tapm
. mat list R

R[15,2]
             min        max
tapm  9.2814722   33.19886
tapm  14.534559  41.245491
tapm  .69664574  27.997656
tapm  1.9050874   19.26358
tapm  2.2546427  23.649343
tapm  18.823215  95.660553
tapm  29.756449        100
tapm  .89071411  11.978825
tapm  1.7059844  52.421001
tapm   5.090116  133.49698
tapm  .05324766  25.279753
tapm   .1555686  81.826134
tapm  1.7540972  39.627739
tapm  2.9897394  136.77647
tapm  3.4334259  115.77041

I suppose I could do it with a loop that builds a macro containing
the 15 words, but am I overlooking a better way?

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

Dr Keith B.G. Dear
Senior Fellow in Biostatistics
National Centre for Epidemiology and Population Health
Australian National University
Canberra, ACT 0200, Australia
Tel: 02 612 54865, Fax: 02 612 50740
http://nceph.anu.edu.au/Staff_Students/staff_pages/dear.php
CRICOS provider #00120C

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