Statalist


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

Re: st: rowshape of a matrix - stata10-


From   Tirthankar Chakravarty <tirthankar.chakravarty@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: rowshape of a matrix - stata10-
Date   Wed, 2 Sep 2009 20:49:50 +0100

If you would like to use Mata, here's how it can be done:
**********************
clear*
mat define A=( 379 , .1876086\  484 , .31070169)
mat colnames A = N  mean
mat rownames A = 0 1
mat list A
mata: st_matrix("B", rowshape(st_matrix("A"), 1))
mat list B
**********************

On Wed, Sep 2, 2009 at 8:01 PM, Herve STOLOWY<stolowy@hec.fr> wrote:
> Dear Statalisters:
>
> I get the matrix m1 with the following command:
>
> statsmat foreign_rel, s(N mean) by(year_d2) mat(m1), if treatment==1
>
> m1[2,2]
>           N       mean
> 0        379  .18760868
> 1        484  .31070169
>
> I would like to reshape this matrix to get  everything in one line:
>
>  N       mean    N Mean
> 0/1       379  .18760868  484  .31070169.
>
> It is possible?
>
> I found the rowshape command but don't know how to use it. I understood that it is based on Mata but never used Mata. I tried something:
>
> mata
> rowshape (m1,2)
>
> but get an error message: <istmt>:  3499  m1 not found.
>
> Would you have an idea?
>
> Best regards
>
> Herve Stolowy
>
>
>
>
>
>
>
>
> ***********************************************************
> Professeur/Professor
> HEC Paris
> Departement Comptabilite Controle de gestion / Dept of Accounting and Management Control
> 1, rue de la Liberation
> 78351 - Jouy-en-Josas
> France
> Tel: +33 1 39 67 94 42 - Fax: +33 1 39 67 70 86
> mail: stolowy at hec dot fr
> web: http://www.hec.fr/stolowy
>
>
> *
> *   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