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: RE: Save -table- command results

From   "Pablo Bonilla" <>
To   "Stata List" <>
Subject   Re: st: RE: Save -table- command results
Date   Mon, 12 Mar 2012 15:32:44 +0000

Dear Nick,

You'r right, I am sorry for not explain the provenance os -statsmat-. 

Thank you for the suggestion, but still it is faster and more efficient to use the -statsmat- command  because the preserver and the collapse commands are very slow in huge data bases like the one I am using.

That would be great if the -statsmat- command can present results with the by() option for several variables.


Sent via BlackBerry from T-Mobile

-----Original Message-----
From: Nick Cox <>
Date: Mon, 12 Mar 2012 14:58:02 
To: ''<>
Reply-To: statalist@hsphsun2.harvard.eduSubject: st: RE: Save -table- command results

-statsmat- is from SSC (Christopher F. Baum and friend). Please remember to explain the provenance of user-written commands. 

You don't have to use -statsmat- at all to get a matrix. There are many ways of doing it. 

Here is one: 

collapse (sum) var1 var2 var3 var4 var5 [w=factor], by(decil) 
mkmat var*, matrix(mysums) row(decil) 


Pablo Bonilla

I would like to know if there is a way to save the results from the
-table- command in matrices. I am using the -statsmat- command but It
is very inefficient if I need to use it with the by() option.

For instance, this is what I want to save:
table decil [w = factor], c(sum var1  sum var2 sum var3  sum var4 sum
var5)  f(%19.2f) row

But I have to do it in this way in order to get a matrix:
cap mat drop mat1
foreach var in var1 var2 var3 var4 var5 {
	statsmat `var' [w = factor], by(decile) stat(sum) format(%16.0f)
	mat mat1 = nullmat(INCOME),`income'

*   For searches and help try:

*   For searches and help try:

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