Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

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

Re: st: tabstatmat question

From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: tabstatmat question
Date   Thu, 1 Sep 2011 20:47:23 +0100

-tabstatmat- (SSC) is a user-written program. You are expected to explain that.

It just feeds on the last set of r-class results. It cannot look back
in your past to see previous results. The effect of -by:- as a prefix
command is to run -tabstat- repeatedly and to overwrite saved results
each time.

If you issue -tabstat- with a -by()- option you should have more success.


On Thu, Sep 1, 2011 at 8:30 PM, Alvarez,Sergio <[email protected]> wrote:
> Dear Statalisters,
> I'm trying to create a matrix of the grouped means of a variable (num_typ3).
>  The observations in my dataset are grouped by location (zone) and time
> period (wave).
> Ideally the matrix would have the zones as the rows and the waves as the
> columns (or vice-versa), something like this:
>         WAVE
> ZONE      1          2       ...
> 1      mean(1,1)  mean(1,2)
> 2      mean(2,1)  mean(2,2)
> ...
> I would use the matrix to generate a variable that takes the mean value
> depending on the zone and wave, using something like:
> gen meancatch = TABLE[zone,wave]
> I believe I need to go this route, rather than directly creating the
> variable, because I'm creating a set of 'fake' alternatives for each 'real'
> observation, corresponding to each location.  Each observation corresponds
> to a fishing trip, so the alternatives are the possible fishing trips that
> didn't happen.  I'll do that using -reshape-.
> Anyway, I thought -tabstatmat- would do the job, so I tried:
> by zone wave, sort: tabstat num_typ3, stat(mean) save
> Which gives me the elements of the ideal matrix one by one.  Then I try:
> tabstatmat TABLE
> But this returns a 1x1 matrix:
> symmetric table[1,1]
>       num_typ3
> mean  .94892632
> So my question is, where did I mess up?  Or did I just misunderstand what
> -tabstatmat- does?  Is there a convenient way to do this?

*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index