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: syntax and gettoken with parentheses and equal signs
From
Nick Winter <[email protected]>
To
[email protected]
Subject
Re: st: syntax and gettoken with parentheses and equal signs
Date
Thu, 27 Mar 2014 10:23:01 -0400
Another approach from those already suggested: by looking in
-ivregress.ado-, I see that the relevant parsing is handled by
-_ivparse.ado-.
So you could either borrow the code from _ivparse.ado, or, perhaps, just
call that program as-is to do your parsing.
- Nick
On 3/27/2014 9:15 AM, Eric Lewis wrote:
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/
*
* 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/