You can do a reasonable job of this using -table- (and a bit of looping).
I will presume that each observation represents a single study, with a variable called study containing some kind of study id and a variable n for the number of subjects.
qui count if !missing(study)
qui gen pcstudy=1/r(N) if !missing(study)
foreach v of varlist age ses {
su n if !missing(`v'), meanonly
qui gen pcn=n/r(sum) if !missing(`v')
table `v', c(count study sum pcstudy sum n sum pcn)
qui drop pcn
}
David
david@icnarc.org
-----Original Message-----
From: Garrard, Wendy M. [mailto:wendy.garrard@vanderbilt.edu]
Sent: 11 February 2005 20:43
To: statalist@hsphsun2.harvard.edu
Subject: st: custom table of summary stats
Hello Statalist,
I need a rather simple table of summary stats, but having trouble identifying which of the many Stata commands (tabstat, tab, tabi, tab1, etc.) will do what I need. Please, someone point me in the right direction.
The data is for meta-analysis. I am trying to output descriptives for several categorical variables, and the summary statistics per category reflect the count of studies, % of total studies, sum of sample n's, and % of total sample N that contribute to each category. The % of subjects is the element that is making this tricky. There are many categorical variables, so I want to avoid doing this as a piecemeal caclulation.
Categ. Var. Study(n) Study(%) Subj.(n) Subj.(%)
(N=100) (N=1,000)
---------------------------------------------------------
Age
Child 50 .50 400 .40
Teen 50 .50 600 .60
Family SES
Low 35 .35 400 .40
Middle 55 .65 480 .48
High 10 .10 120 .12
etc..............................
Thanks very much,
Wendy
*
* 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/
*
* 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/