Statalist


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

Re: st: matrix question


From   Tirthankar Chakravarty <tirthankar.chakravarty@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: matrix question
Date   Sat, 8 Aug 2009 16:15:36 +0100

<>
Maybe this is what you want? Please note that you have -estout- due to
Ben Jann (SSC).
*********************
clear*
sysuse auto, clear
global loopvars "price mpg weight length turn"
foreach x of varlist $loopvars {
	qui: estpost tab `x'
	mat define matpct = e(pct)
	mat define matcumpct = e(cumpct)
	mat A = (nullmat(A), (matpct[1,1..2] , matcumpct[1, 4])')
}
mat colnames A = "$loopvars"
matlist A
*********************

T


On Sat, Aug 8, 2009 at 3:47 PM, moleps islon<moleps2@gmail.com> wrote:
> I'm all new to the world of matrices and cannot figure out how to use
> them properly. What I'm trying to do is to loop through a bunch of
> variables, tabulating them using estpost tab and save certain cells
> ([1,1..2] & [2,2]) into a new vector and append this vector to my
> result matrix.
>
> e.g. after the estpost tab command I've got two vectors (copied from
> e(pct) and e(cumpct)) A(1,2,3,4) & B(2,4,6,7). What I need now is to
> create a new vector containing A[1,1..2] & B[1,4] and append it to my
> matrix J.
> In the end matrix J should have one vector for each of the variables
> and be displayed...
>
> I'm sure this is easy, but I'm new to this and cannot figure out the
> notation used in the manuals.
>
> Reg,
> M
> *
> *   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/
>



-- 
To every ω-consistent recursive class κ of formulae there correspond
recursive class signs r, such that neither v Gen r nor Neg(v Gen r)
belongs to Flg(κ) (where v is the free variable of r).

*
*   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   |   What's new   |   Site index