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

Re: st: tabulation of means, by group

From   Svend Juul <SJ@SOCI.AU.DK>
To   <>
Subject   Re: st: tabulation of means, by group
Date   Mon, 28 Jul 2008 10:24:36 +0200

Michael McCulloch wrote:
In the following simulated data, I'd like to create a table of mean age (row header) for:
each of 3 income levels (with income level the column sub-header)
within each of 2 groups (with group the column main header)
So that:
from left to right in the data area would groups 1, 2, and 3,
within each group, from left to right would be income categories
And in each cell the mean age.
Here are the data I've created:
set obs 100
set seed 12358
gen age =30 + int(20*uniform())
format age %2.0f
gen income =1 + int(3*uniform())
gen group =1 + int(2*uniform())

It seems that you want a table with one row. The -table-
command interprets the first variable as the row variable,
so generating a variable with one value will do the trick.
That variable may even be a string variable:
   generate str meanage = "Mean age"
   table meanage group income , contents(mean age)
Hope this helps
Svend Juul
Institut for Folkesundhed, Afdeling for Epidemiologi
(Institute of Public Health, Department of Epidemiology)
Vennelyst Boulevard 6 
DK-8000 Aarhus C,  Denmark 
Phone, work:   +45 8942 6090 
Phone, home:   +45 8693 7796 
Fax:           +45 8613 1580 

*   For searches and help try:

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