Statalist


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

Re: st: Appearance of Matrix row and column labels.


From   "Sergiy Radyakin" <[email protected]>
To   [email protected]
Subject   Re: st: Appearance of Matrix row and column labels.
Date   Wed, 19 Nov 2008 11:11:14 -0500

No, the values corresponding to the rownames are saved into the matrix
values of e(Row). Use a loop to form a local and then use that local
as rownames, e.g.:

      version 10.0
      sysuse auto
      svyset [pw=weight]
      svy: tab rep78
      matrix RNAMES=e(Row)
      forvalues i=1/`=colsof(RNAMES)' {
        local rnames `rnames' `=RNAMES[1,`i']'
        *** in the perfect world Stata would not require the {-} brackets here
      }
      matrix PROP=e(b)'
      *** note that e(b) must be transposed
      matrix rownames PROP = `rnames'
      matrix list PROP

Best regards,
    Sergiy Radyakin

On Wed, Nov 19, 2008 at 10:59 AM, Friedrich Huebler <[email protected]> wrote:
> Daniel,
>
> I am not sure what you mean by "where to put the e(Row) to set the
> rownames." Could you be more specific? To extract the rownames use
> this command:
>
> . local lclname : rownames e(Row)
> . di "`lclname'"
>
> See -help extended_fcn-. You would benefit from reading the entries
> related to matrices in the Programming manual.
>
> Friedrich
>
> On Wed, Nov 19, 2008 at 5:58 AM, Daniel Schultz <[email protected]> wrote:
>> Maybe I just don't get it.
>> I know now that the names are saved into e(Row) but where to put it:
>>
>> mat `var' == (e(Prop)\e(total))
>>
>> gives me the wanted  proportions but with the described rownmaes.
>>
>> mat rown `var' = e(Row)
>>
>> is not working.
>> So where to put the e(Row) to set the rownames. Sorry for the stupid
>> question, I am not so familiar with setting up the matrices.
>>
>> Best
>> Daniel
>>
>> 2008/11/18 Sergiy Radyakin <[email protected]>:
>>> Hello Daniel,
>>>
>>> -svy: tab- saves row names into e(Row). Use these values to name
>>> (programmatically) your rows in e(Prop).
>>> Beware of the decimal point: Stata does not allow decimal points in
>>> rownames, better replace it with something else.
>>>
>>> Best regards,
>>>  Sergiy Radyakin
>>>
>>>
>>>
>>>
>>>
>>> On Mon, Nov 17, 2008 at 6:38 PM, Daniel Schultz <[email protected]> wrote:
>>>> Hej Stata-users....
>>>>
>>>> maybe this is a trivial problem, but I worked for several days on the
>>>> solution and couldn't find one.
>>>>
>>>> So here is the description of the problem:
>>>>
>>>> My purpose is to extract a matrix out of the svy: tab command. So my
>>>> do-file (partly) looks like this:
>>>>
>>>> svy: tab `var'
>>>> mat `var' = e(Prob)
>>>>
>>>> If I now list the matrix with the
>>>>
>>>> mat list `var'
>>>>
>>>> command, all my rows are named y1 and all my columns are named p11.
>>>> Obviously I would like to get the characteristic names as rows. Since
>>>> this is part of a loop I can't do it manually with mat rown = a b c.
>>>> Here an example how it looks like at the moment:
>>>>
>>>> Q0001_02
>>>>
>>>>       p11
>>>> y1    .578
>>>> y1    .321
>>>> y1    .111
>>>>
>>>> Do you have an idea how I can get rid of the y1 and put in the characteristics?
>>>>
>>>> Since I do this for around 1800 variables via a loop, I can't do this
>>>> every time by hand.
>>>> has anybody an idea. This problem also occurs if I want to add the
>>>> number of observations with
>>>>
>>>> mat `var' = (e(Prob)/e(N))
>>>>
>>>> This would be the next step to do.
>>>>
>>>> Best Daniel
> *
> *   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/



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