Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: table with by() option


From   "Thomas Erdmann" <[email protected]>
To   <[email protected]>
Subject   st: table with by() option
Date   Wed, 24 Jan 2007 12:32:18 +0100

Hi - 

I have several group sort-variables (portfolios), and one returns variable.
So my output is for each group separately

var1_group	mean(ret)
1		0.05
2		0.1
.		.
5		0.3


Var2_group	mean(ret)
1		0.1
2		0.2
.		.
5		0.4


Which I obtain by 
foreach X of varlist var1_group var2_group var3_group {
oneway ret G_`X', tab
}

Which was ok so far for analysis, but for presentation it would be easier if
the format was more compact like

Ret(mean)		1		2	...		5	
Var1_group		0.05		0.1	..		0.3	
Var2_group		0.1		0.2	..		0.4
..


I tried several versions with of -tabstat- , but I don't arrive at the table
I'm aiming for (also see below). Is there probably an easy way without
generating additional variables for the group means?

- Tom



tabstat  F15M9etrs, c(v) varwidth(16) s(mean) by( G_r_eqy_ta)
G_r_eqy_ta    stats |  F15M9e~s
--------------------+----------
1              mean |  .0105481
2              mean |  .0118868
3              mean |  .0115413
4              mean |  .0084859
5              mean |  .0081082
6              mean |  .0071197
7              mean |  .0066859
8              mean |  .0095878
9              mean |  .0099924
10             mean |  .0075656
--------------------+----------
Total          mean |  .0091163
-------------------------------

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   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