Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: invalid syntax of marksample depending on option specified in preceding line for syntax?
From
Nick Cox <[email protected]>
To
[email protected]
Subject
Re: st: invalid syntax of marksample depending on option specified in preceding line for syntax?
Date
Wed, 28 Mar 2012 00:32:09 +0100
The effect of your -weight()- option is inevitably to create a local
macro -weight- and that is evidently being noticed by -marksample- in
a way that you don't want. I suggest it is much simpler to use
standard syntax to specify weights, or if you have reasons not to do
that to use a name other than -weight-. That could include using a
name like -weight1-, specifying that it can be abbreviated to "weight"
by WEIGHT1(varname) and even telling the user that the name is
-weight()- (although an experienced user might be puzzled by being
asked to specify weights via an option).
For related tricks see
Cox, N.J. 2009. Stata tip 79: Optional arguments to options. Stata
Journal 9(3): 504
Nick
2012/3/27 László Sándor <[email protected]>:
> This might be a one-liner for one of you, but I'd appreciate the help.
> My ado file (currently tested on Stata 12.1 for Mac, but starting with
> "version 10.1") includes the lines:
>
> syntax varlist [if/] [, Weight(varname) nbins(integer 20)
> controls(varlist) absorb(varname) x_q(varname) connect NOAddmean
> reportreg create_xq saving(string) *]
> marksample touse
>
> Now all works fine until I try to specify a weight. Because having a
> ", weight(w)" option (variable w exists) gives me a syntax error — but
> not for the syntax command, but for marksample.
>
> Trace:
> - syntax varlist [if/] [, Weight(varname) nbins(integer 20)
> controls(varlist) absorb(varname) x_q(varname) connect NOAddmean
> reportreg create_x
>> q saving(string) *]
> - marksample touse
> invalid syntax
>
> What is this about?
*
* 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/