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

st: RE: RE: custom table of summary stats


From   "David Harrison" <[email protected]>
To   <[email protected]>
Subject   st: RE: RE: custom table of summary stats
Date   Mon, 14 Feb 2005 14:08:37 -0000

Sorry, code should have been:

foreach v of varlist age ses {
	qui count if !missing(study) & !missing(`v')
	qui gen pcstudy=1/r(N) if !missing(study) & !missing(`v')
	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 pcstudy pcn
}

-----Original Message-----
From: David Harrison 
Sent: 14 February 2005 14:06
To: [email protected]
Subject: st: RE: custom table of summary stats


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
[email protected]


*
*   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