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

st: sample size program


From   Friederike Barthel <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   st: sample size program
Date   Mon, 27 Jan 2003 15:47:33 -0000

Dear list

i have written the following program in order to calculate the sample size
(i want to advance on it which is why i didnt use sampsi) but it returns an
error message and I can't spot the error at present.

program define sampsi1

version 7.0

syntax [, ZAlpha (real 1.645) ZPower (real 0.8416) HRatio (real 1.5) CEnsor
(real 0.8) PControl (real 0.5)]

if "`ZAlpha'"==" {
ret local errmess "zalpha required"
exit 198
}

if `zalpha'<=0 {
ret local errmess "zalpha() out of range"
exit 198
}

if "`zpower'"==" {
ret local errmess "zpower required"
exit 198
}

if `zpower'<=0 {
ret local errmess "zpower() out of range"
exit 198
}

if "`hratio'"==" {
ret local errmess "hratio required"
exit 198
}

if `hratio' <= 0 {
ret local errmess "hratio out of range"
exit 198
}

if "`censor'"==" {
ret local errmess "censor required"
exit 198
}

if `censor'<=0 | `censor'>=1 {
ret local errmess "censor out of range"
exit 198
}

if "`pcontrol'"==" {
ret local errmess "pcontrol needed"
exit 198
}

if `pcontrol'<=0 | `pcontrol'>=1 {
ret local errmess "pcontrol out of range"
exit 198
}

tempname N0 N1 N2 N

scalar `N0' = (`ZAlpha'+`ZPower')^2
scalar `N1'=(log(`HRatio'))^2
scalar `N2'=`CEnsor'*`PControl'*(1-`PControl')
scalar `N'=`N0'/(`N1'*`N2')

return N=`N'

end

exit

Thank you for your help

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