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

st: gen vars from ci or cii commands


From   "Douglas Crawford" <dcrawfo@itsa.ucsf.edu>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: gen vars from ci or cii commands
Date   Thu, 12 Aug 2004 14:28:29 -0700

Hello,

In preparation for using rcap I want to create two variables: upper and
lower confidence intervals for a proportion in my data.  I have already
collapsed the data set.  I know that I can use 

cii obs successes, binomial

to generate the appropriate information.  My question is, Is there a way of
generating a variable = to the r(ub) and r(lb)?

I tried the following without success:

levels treat, local(groups)
gen pct_bag_ub 	= .
gen pct_bag_lb 	= .
gen pct_bag_se 	= .
gen pct_bag_mn 	= .
gen N			= .

foreach group of local groups {
	cii obs successes if treat = "`group'"
	replace pct_bag_ub	= r(ub)	if strain_treat == "`group'"
	replace pct_bag_lb	= r(lb)	if strain_treat == "`group'"
	replace pct_bag_mn	= r(mean)	if strain_treat == "`group'"
	replace pct_bag_se	= r(se)	if strain_treat == "`group'"
	replace N			= r(N)	if strain_treat == "`group'"
}

But cii does not support if (nor does ci).

I also tried statsby, but ci does not appear to be supported command.

Thanks as always for your help.

Cheers,

Douglas



*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index