Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: Save -tabulate- output as matrix

From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: Save -tabulate- output as matrix
Date   Wed, 13 Oct 2004 19:03:36 +0100

I agree: it's a simple problem. But I'm never 
surprised that there aren't canned ways to 
do things like this, as there are hundreds of 
such simple things that might be wanted, and 
far fewer commands. 

Various things come close. The easiest way to do this 
I can think of is 

	contract ... , freq(freq) percent(percent) 
	mkmat freq percent, matrix(mymatrix) 
	levels ..., local(levels) 
	mat rownames mymatrix = `levels' 

You could hack at a clone of -groups- (SSC) 
to make it save matrices optionally. 

[email protected] 

Friedrich Huebler

> I am looking for a way to save -tabulate- output as a matrix, with
> row names and preferably without the "Total" row. This would be
> similar to the way -tabstatmat- converts -tabstat- output to a
> matrix. With the matcell, matcol and matrow options some of the
> -tabulate- results can be saved but I don't know how to save the
> value labels and the percent values. The following example makes
> clear what exactly I would like to do.
> . sysuse auto
> . tab foreign
> Car type |      Freq.     Percent        Cum.
> ---------+-----------------------------------
> Domestic |         52       70.27       70.27
>  Foreign |         22       29.73      100.00
> ---------+-----------------------------------
>    Total |         74      100.00
> I would like to create a matrix that looks like this:
> tab[2,2]
>           freq  percent
> Domestic    52    70.27
>  Foreign    22    29.73
> This appears to be a simple problem but I could not find a solution
> in the manuals, with -findit- or in the Statalist archives.

*   For searches and help try:

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