Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: RE: Invalid syntax in a program


From   Eric Booth <ebooth@ppri.tamu.edu>
To   "<statalist@hsphsun2.harvard.edu>" <statalist@hsphsun2.harvard.edu>
Subject   Re: st: RE: Invalid syntax in a program
Date   Mon, 12 Jul 2010 19:26:39 +0000

<>

Works for me too.   Try turning on your trace to see where it stops (-set trace on-)

~ Eric
__
Eric A. Booth
Public Policy Research Institute
Texas A&M University
ebooth@ppri.tamu.edu
Office: +979.845.6754


On Jul 12, 2010, at 2:24 PM, Martin Weiss wrote:

> 
> <>
> 
> 
> Does work for me:
> 
> ***********
> capture program drop command
> program command, rclass
> version  10.0
> syntax varlist(min=1 max=10)
> foreach v of local varlist {
> 	di in r "`v'"
> }
> end
> 
> drop _all
> 
> gen var1=.
> gen var2=.
> command var1 var2
> ***********
> 
> 
> HTH
> Martin
> 
> 
> -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu
> [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Dani Tilley
> Sent: Montag, 12. Juli 2010 21:19
> To: stata
> Subject: st: Invalid syntax in a program
> 
> Hi,
> 
> I'm trying to write a program that will do some fairly  involved
> manipulations 
> on variables. I'll spare you the code, but  I've tried it several times and
> it 
> works just fine. When I try to write a command that will do those operations
> for 
> me, I get invalid syntax.
> 
> capture program drop command
> program command, rclass
> version  10.0
> syntax varlist(min=1 max=10)
> foreach v of local varlist {
> <working  code goes here>
> }
> end
> 
> command var1 var2
> invalid  syntax r(198);
> 
> I also tried the following manually (not in a  program):
> 
> local b var1 var2
> foreach v of local b{
> <working  code>
> } 
> 
> and everything went smoothly. So I'm completely  baffled as to why this
> wouldn't 
> 
> 
> work in a program with -foreach v of  local varlist-.
> 
> Any help is appreciated.
> 
> Thanks,
> DF  Tilley
> 
> 
> 
> *
> *   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/





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


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