This is great! I just learned a new thing in stata from you today.
Thanks Scott!
-m
>>> <[email protected]> 9/14/2006 2:08 PM >>>
-set trace on- would reveal this error. For example:
. sysuse auto,clear
(1978 Automobile Data)
. set tracedepth 1
. set trace on
. local v1 "mpg gear"
. local samp1 "if fore==0"
. foreach v of varlist `v1' {
2. sum `v' if `samp1'
3. }
- foreach v of varlist `v1' {
= foreach v of varlist mpg gear {
- sum `v' if `samp1'
= sum mpg if if fore==0
if not found
}
r(111);
Also, in your -sum- statement should it not be -sum `v'- not -sum
`v1'-
?
Scott
----- Original Message -----
From: Michael Blasnik <[email protected]>
Date: Thursday, September 14, 2006 1:00 pm
Subject: st: Re: syntax error using summarize command inside a macro
To: [email protected]
> You have the if in the command and also in the macro so that Stata
> sees "if
> if"
>
> M Blasnik
>
> ----- Original Message -----
> From: "Marcella Sapun" <[email protected]>
> To: <[email protected]>
> Sent: Thursday, September 14, 2006 1:33 PM
> Subject: st: syntax error using summarize command inside a macro
>
>
> > Hi there,
> >
> > I am trying to produce a summary statistics on a series of
variables
> > using the command SUM inside a macro subroutine. Apparently, my
> > "try=off" program (see below) is not working because a syntax
> error. I
> > cannot find the error. Would anybody be able to see it?
> >
> > Thanks!
> >
> <snip>
> > . local samp1 "if prown3==0"
> >
> > . foreach v of varlist `v1' {
> > 2. sum `v1' if `samp1' [aw=`v1']
> > 3. }
> > if not found
> > r(111);
>
>
*
* 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/
*
* 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/