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

From |
moleps islon <moleps2@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: matrix question |

Date |
Sat, 8 Aug 2009 17:47:33 +0200 |

That is exactly what I'm looking for, however applying your code to my program doesnt work ( though your code works beautifully). I end up with r503 conformability error. And also instead of a [8,4] matrix I get a [1,24] matrix. Moleps capture program drop bif_des program bif_des capture drop _* quietly des,varlist local r `r(varlist)' di "`r'" tokenize `r' local first `1' macro shift local rest `*' local t:word count `rest' tokenize `rest' forval o=2(2)`t' { local rowname `rowname' ``o'' gen _``o''pos=1 if (``o''>0 & ``o''<.) replace _``o''pos=0 if (``o''<0) estpost tab _``o''pos,mi matrix def o=e(pct) matrix def l=e(cumpct) mat A=(nullmat(A),(o[1,1..2],l[1,2])') mat list A } mat rownames A = `rowname' end On Sat, Aug 8, 2009 at 5:15 PM, Tirthankar Chakravarty<tirthankar.chakravarty@gmail.com> wrote: > <> > 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/ > * * 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/

**References**:**st: matrix question***From:*moleps islon <moleps2@gmail.com>

**Re: st: matrix question***From:*Tirthankar Chakravarty <tirthankar.chakravarty@gmail.com>

- Prev by Date:
**Re: st: matrix question** - Next by Date:
**st: matrix question** - Previous by thread:
**Re: st: matrix question** - Next by thread:
**st: matrix question** - Index(es):

© Copyright 1996–2017 StataCorp LLC | Terms of use | Privacy | Contact us | What's new | Site index |