Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

st: Subsetting a -return- matrix in a single step


From   Bert Jung <bjung59@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: Subsetting a -return- matrix in a single step
Date   Fri, 10 Sep 2010 17:50:37 -0400

Dear Statalisters,

I would like to subset a -return- matrix.  In the past I used two
steps but now hope to upgrade to the 1-step solution, if it exists?

Thanks,
Bert


*** Example: using tabstat just to produce some r(matrix) to play with

tabstat foreign turn weight length headroom, stat(mean sd q) save
return list

mat list r(StatTotal)

*** Say I want the first 3 rows and 2 columns of this matrix.  Can the
following be done in a single step?

mat A = r(StatTotal)
mat A = A[1..3,1..2]

mat list A

*** Obviously this generates a syntax error
mat B = r(StatTotal)[1..3,1..2]
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index