[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
RE: st: weight option after syntax
That solves my problem. Thanks a million!
Department of Sociology
Indiana University at Bloomington
From: "Scott Merryman" <email@example.com>
Subject: RE: st: weight option after syntax
Date: Sun, 25 Sep 2005 19:41:58 -0500
I suspect the problem is that "namelist" requires that the names listed use
the standard naming convention and names cannot begin with "[" If you use
the "if" option then parser knows that what follows cannot be part of
One alternative is to use "anylist"
program mycmd, rclass byable(recall)
syntax anything [if] [in] [pweight]
gettoken subcmd anything: anything
gettoken lhs anything: anything
loc rhs `anything'
di in r "`subcmd'"
di in r "`lhs'"
di in r "`rhs'"
di in r "`weight'"
di in r "`exp'"
Which now works:
. mycmd fubar price mpg weight [anyhoo = (American) anyhow] [pw = fore]
mpg weight [anyhoo = (American) anyhow]
Hope this helps,
> -----Original Message-----
> From: firstname.lastname@example.org [mailto:owner-
> email@example.com] On Behalf Of Jun Xu
> Sent: Sunday, September 25, 2005 5:24 PM
> To: firstname.lastname@example.org
> Subject: RE: st: weight option after syntax
> Sorry that I forgot to mention that I am using Stata 9.1.
> Jun Xu
> Ph.D. Candidate
> Department of Sociology
> Indiana University at Bloomington
> >From: "Jun Xu" <email@example.com>
> >Reply-To: firstname.lastname@example.org
> >To: email@example.com
> >Subject: st: weight option after syntax
> >Date: Sun, 25 Sep 2005 17:14:19 -0500
> >I think I must miss something important here. I am trying to write a
> >command that simply invokes a stata command repeatedly and collect some
> >eret information. The following is the very beginning part of it (also
> >where the problem lies), and I am having problems with the [pw] option.
> >inserted display commands to check if I am getting macro's that I want.
> >thoughts? Thanks a lot!
> > cap program drop mycmd
> > program mycmd, rclass byable(recall)
> > version 8.0
> > syntax namelist [if] [in] [pw]
> > gettoken subcmd namelist: namelist
> > gettoken lhs namelist: namelist
> > loc rhs "`namelist'"
> > di in r "`subcmd'"
> > di in r "`lhs'"
> > di in r "`rhs'"
> > di in r "`weight'"
> > di in r "`exp'"
> > end
> >Everytime I launch the command by specifying weight option alone, I
> >get an error message. Note that lwg is a real variable name and I have
> >working data set in memory.
> >. mycmd this is another issue [pw=lwg]
> >[ invalid name
> >end of do-file
> >However, if I work off a real data set and specify if condition before
> >[pw=lwg], everything works fine. Note here k5 is a real variable.
> >. mycmd this is another issue if k5==3 [pw=lwg]
> >another issue
> >= lwg
* For searches and help try:
Express yourself instantly with MSN Messenger! Download today - it's FREE!
* For searches and help try: