Statalist


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

Re: st: AW: simple question on two-way table


From   Austin Nichols <austinnichols@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: AW: simple question on two-way table
Date   Wed, 18 Feb 2009 10:20:05 -0500

Shehzad Ali <sia500@york.ac.uk>:
Yes, the by option should used, not the by prefix--I copied the
tabstat call from a prior msg without really looking at it.
Try this:

cd `c(sysdir_personal)'
tabstat A B C D E F G H I J, stat(mean sd median min max) col(stat)
by(week) save
tabstatmat a
mat A=a'
xml_tab A, save(a.xls) replace
!a.xls

as you should have write access to c(sysdir_personal) at least...

On Wed, Feb 18, 2009 at 6:36 AM, Nick Cox <n.j.cox@durham.ac.uk> wrote:
> The error message for -xml_tab- suggests some issue with your write
> access, which you don't detail.
>
> I would expect that -tabstat- under the aegis of -by:- would save only
> the last results it produced. So that is all that -tabstatmat- could
> possibly see. Here is one test supporting that. Note that I don't get
> the error message Shehzad reports.
>
> . sysuse auto
> (1978 Automobile Data)
>
> . by foreign : tabstat mpg, save
>
> ------------------------------------------------------------------------
> ---------
> -> foreign = Domestic
>
>    variable |      mean
> -------------+----------
>         mpg |  19.82692
> ------------------------
>
> ------------------------------------------------------------------------
> -------
> -> foreign = Foreign
>
>    variable |      mean
> -------------+----------
>         mpg |  24.77273
> ------------------------
>
> . ret li
>
> matrices:
>          r(StatTotal) :  1 x 1
>
> . tabstatmat foo
>
> symmetric foo[1,1]
>            mean
> Total  24.772727
>
> Nick
> n.j.cox@durham.ac.uk
>
> Shehzad Ali
>
> Thank you, Martin, Neil and Austin. All the suggestions were very
> helpful.
>
> Here are quick follow-up questions for Austin:
>
> 1. Following the -tabstatmat- code, -xml_tab A, save(a.xls) replace-
> gives
> me the following error:
>
> -file can not be saved at this location-
>
> Looking at the help file for xml_tab, it suggests closing Excel files
> but I
> don't have any open.
>
> 2. When I tried:
>
> bysort week: tabstat A B C D E F G H I J, stat(mean sd median min max)
> col(stat) save
>
> tabstatmat a
>
> I get the following error: - no tabstat results in memory-
>
> Instead if I tried:
>
> tabstat A B C D E F G H I J, stat(mean sd median min max) col(stat)
> by(week) save
>
> tabstatmat a
>
> It worked. I don't why.
>
*
*   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