Nick,
Your explanation is very helpful. I will try it again.
Marcella
>>> Nick Cox <[email protected]> 9/14/2006 2:05 PM >>>
First, what you are writing is called a macro in some other
languages, but not in Stata. Keep the terminology for
some alternative software you may have encountered.
You can assign
. local vars "var1 var2 var3 var4 var5 var6 var7 var8 var9 var10 var11
var12 ... varn";
and that is legal. At that point the local is just a string, and its
contents
are under your control. But Stata cannot make sense of this when you
want to interpret it as a varlist. It will choke at the "...".
Alternatively, my guess is that this is _not_ what you wrote, in which
case you are just confusing the issue by posting a mix of real code
and
pseudocode.
I sense various other typos and unnecessary complexities in the code.
The one that is halting your code is probably that after substitution
the line
sum `v1' if `samp1' [aw=`v1']
will be
sum <all your variables> if if prown3 == 0 [aw=<all your variables>]
This is most unlikely to be what you want, but the "if if" is what
Stata is choking on, as it is trying to tell you.
A more general comment is that you are trying to run when walking
will do the job very well. Setting up a loop is not needed as
-summarize- does that for you.
Your code seems to boil down to
-------------------------------------
set mem 67m
use "C:\newset.dta"
su <varlist> if prown3 == 0
-------------------------------------
in which you need to plug your variable names into <varlist>,
except that I cannot work out how you want to apply weights.
Nick
[email protected]
Marcella Sapun
>
> 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?
>
> --------------------------------------------------------------
> -------------------------------------------------
> . do "C:\univariates.do"
> .
> . set mem 67m
> (68608k)
>
> .
> . use "C:\newset.dta"
> .
> .
> . #delimit;
> delimiter now ;
> . local vars "var1 var2 var3 var4 var5 var6 var7
> > var8 var9 var10 var11 var12 ... varn";
>
> . #delimit cr
> delimiter now cr
> .
> . local v1 "`vars'"
> .
> . local samp1 "if prown3==0"
>
> . foreach v of varlist `v1' {
> 2. sum `v1' if `samp1' [aw=`v1']
> 3. }
> if not found
> r(111);
>
> end of do-file
> 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/