Bookmark and Share

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: options for syntax checking do files before running


From   Christopher Zbrozek <[email protected]>
To   [email protected]
Subject   Re: st: options for syntax checking do files before running
Date   Tue, 9 Apr 2013 22:48:14 -0400

Thanks, Nick!

I agree it's best to use Stata's syntax checker... and, cough, ahem,
if anyone from Statacorp is listening, if users had the ability in a
future release to quickly scan a dofile for syntax errors using the
executable's syntax checker (without actually needing running the code
on a dataset), you'd have some happy users in Ann Arbor.

Best,
Christopher Zbrozek
University of Michigan

On Mon, Apr 8, 2013 at 3:55 PM, Nick Cox <[email protected]> wrote:
> I don't think there is any such program. It would be foolish of me to
> rule out the possibility of some script that catches common errors,
> but my experience is that it is best to let Stata itself find your
> bugs and miscodings as fast as possible.
>
> Nick
>
> Nick
> [email protected]
>
>
> On 8 April 2013 20:28, Christopher Zbrozek <[email protected]> wrote:
>> Hello world,
>>
>> Is anyone aware of user-written code that would review a do file to
>> ensure commands are written using valid Stata syntax? Or,
>> alternatively, is there a way to exploit the Stata executable's
>> internal syntax checker for this purpose?
>>
>> The idea is that because Stata code is interpreted rather than
>> compiled, clearly boneheaded syntax errors aren't caught until
>> runtime. For example, when insufficiently caffeinated this morning, I
>> tried to use a command along the lines of
>>
>> replace myvar = "something" if missing(myvar) | if regexm(myvar, "myregex")
>>
>> which, with that second "if" in there, works about as well as one
>> thinks it should.
>>
>> One (quasi-)solution is of course to debug code using a small sample
>> dataset before running it on millions of observations, which
>> ameliorates but doesn't fix the problem. A rather laborious solution
>> would be to write an ado file or Perl script or something to find
>> common syntax errors and run that at the top of a do file on the text
>> of the do file itself. An ideal solution would be to somehow employ
>> the syntax checking Stata will perform anyway rather than trying to
>> reverse-engineer that portion of the Stata executable.
>>
>> Many thanks,
>>
>> Christopher Zbrozek
>> University of Michigan
>> *
>> *   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/
*
*   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index