Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

st: options for syntax checking do files before running


From   Christopher Zbrozek <zbrozek@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: options for syntax checking do files before running
Date   Mon, 8 Apr 2013 15:28:31 -0400

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/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index