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

st: Parsing of multiple -if- lines


From   "Nick Winter" <nwinter@policystudies.com>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: Parsing of multiple -if- lines
Date   Tue, 13 Aug 2002 08:41:52 -0400

Greetings,

Am I missing something obvious, or is there something weird about how
Stata chokes on the following program -mytest-, but does not choke on
-mytest2-?  That is, using a macro to selectively comment out lines of
code seems to work, except when it is within an -if- block :

program define mytest
   if `1'==1 {
	`2' if `3'==1 {
	`2'	di "three is set to one"
	`2' }
   }
   else {
	`2' if `3'==1 {
	`2'	di "three is set to one"
	`2' }
   }
end

prog define mytest2

	`2' if `3'==1 {
	`2'	di "three is set to one"
	`2' }

end

. mytest 1 " " 1
three is set to one
unrecognized command:  } invalid command name
r(199);

. mytest 1 "*" 1
unrecognized command:  } invalid command name
r(199);

. mytest2 1 " " 1
three is set to one

. mytest2 1 "*" 1


--Nick Winter

-----------------------------------------------------------
 Nicholas Winter, Ph.D.                     P 202.939.5343
 Policy Studies Associates                  F 202.939.5732
 1718 Connecticut Avenue, NW     nwinter@policystudies.com
 Washington, DC 20009-1148           www.policystudies.com
----------------------------------------------------------- 

<<winmail.dat>>




© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index