# st: RE: problem with -IF- condition

 From "Kieran McCaul" To Subject st: RE: problem with -IF- condition Date Fri, 4 Dec 2009 05:24:54 +0800

```...

if `r(p)' > 0.05  {
display  as result "NOT A GOOD INSTRUMENT => FIND A NEW ONE "
}
else {
display as result  " GOOD INSTRUMENT => CONTINUE"
predict e_`x' , ue
gen var_e_`x' =e(sigma)^2
}

______________________________________________
Kieran McCaul MPH PhD
WA Centre for Health & Ageing (M573)
University of Western Australia
Level 6, Ainslie House
48 Murray St
Perth 6000
Phone: (08) 9224-2701
Fax: (08) 9224 8009
email: Kieran.McCaul@uwa.edu.au

http://myprofile.cos.com/mccaul
http://www.researcherid.com/rid/B-8751-2008
______________________________________________
If you live to be one hundred, you've got it made.
Very few people die past that age - George Burns

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Leila Ben Aoun
Sent: Friday, 4 December 2009 12:34 AM
To: statalist@hsphsun2.harvard.edu
Subject: st: problem with -IF- condition

I have a huge do file to run and I try to simplify the procedure which
is quite repetitive but I face to 2 problems quite similar.
If you have any idea it would be welcome !
1-
in my do -file I put ;
foreach sec_var of local secteur {
foreach x of local it_var  {
xtreg `x'  `list_step1' if `sec_var'==1, re
test IV=0
local test_IV=r(p)
display  as result "NOT A GOOD INSTRUMENT => FIND A NEW ONE "
if `r(p)'>0.05 and stop this part of the do-file
display as result  " GOOD INSTRUMENT => CONTINUE"  if `r(p)'<0.05
predict e_`x' , ue
gen var_e_`x' =e(sigma)^2
}
}

How could I run this lines without bug because the "if" is not allowed

2-Secondly I have a similar trouble i have a first regression like
xtprobit Y var1 var2  var3 , re
test var3==0
xtprobit Y var1 var2  var3 , re vce(boot)  if  `r(p)'<0.05 and
continue the do file if not

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```