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]
st: syntax and gettoken with parentheses and equal signs
From 
 
Eric Lewis <[email protected]> 
To 
 
[email protected] 
Subject 
 
st: syntax and gettoken with parentheses and equal signs 
Date 
 
Thu, 27 Mar 2014 09:15:36 -0400 
Dear Statalist
I am trying to write an IV-type estimator that allows for parentheses
(for the first stage regression). I understand that gettoken with the
"bind" option can help with parentheses. However I am having a hard
time implementing that in practice. How can I use gettoken and/or
syntax in this setting?
e.g., I want a program that can define the macros lhs, exog, endog,
and inst based on arguments and the position of parentheses and the
equal sign.
program test_parentheses
     * example syntax y z1 z2 z3 (x1 x2 = z4 z5)
    * syntax and/or gettoken code:
     . . .
    display "`lhs'"
          * displays y
     display "`exog'"
          * displays z1 z2 z3
     display "`endog'"
          * displays x1 x2
     display "`inst'"
          * displays z4 z5
end
Currently I am taking the easy way out and using many options:
syntax [if] [in], lhs(varname) exog(varlist) endog(varlist) inst(varlist)
Thank you,
Eric
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/