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

st: re: syntax

From   Kit Baum <>
Subject   st: re: syntax
Date   Sun, 19 Oct 2008 11:24:09 -0400

< >
Dave said

I have not used syntax much. When I write the syntax command,

syntax varlist(min=2 max=2 numeric) [if] [in] [, noconstant]

I find it parses

mycommand weight weight2 , constant

differently than

mycommand weight weight2, constant

The top parses `2' to weight2 and the bottom parses `2' to weight2,
(includes the comma). Use of tokenize varlist avoids this problem, but
is it a long standing feature of syntax to require option commas to be
separated by white space? I can't remember being careful about how I
type that interactively.

Rather than using numbered macros with -syntax-, just use the returned -varlist-:

program dave
syntax varlist(min=2 max=2 numeric) [if] [in] [, noCONStant]
di " varlist is `varlist'"
di " constant is `constant'"

sysuse auto,clear
dave price mpg , cons
dave price mpg,nocons
dave price mpg , nocons

Kit Baum, Boston College Economics and DIW Berlin
An Introduction to Modern Econometrics Using Stata:

*   For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index