****************************************************************************
When using Stata v10 or v11, you may encounter error messages such as model not defined or invalid syntax. If you are sure there is no syntax error, then it may be due to a peculiar version control problem. Please read below for more information or down the PDF file here.
****************************************************************************
This note is for users of Stata v10 and v11 and it explains what to do when you see the error messages model not defined and invalid syntax when running the Stata programs accompanied by the book (such as sfmodel, sf_fixeff, sfpan, etc.). Solutions to the problem are provided. Please note that the same error messages may appear for a range of issues, and here we only address a specific issue attributed to the version control problem.
In essence, the error messages may appear if you fail to declare the version number in a very specific way. Note that the issue cannot be dealt with following the usual version control procedure advocated by Stata. Rather, it has to be done in a specific way as we describe below.
Suppose you want to run the following commands; the first line loads the dataset, the second line sets up the model, and the third line carries out the estimation.
use mydata, clear
sfmodel y, production dist(h) frontier(x1 x2) usigmas(z1) vsigmas()
ml max
If you use Stata version 11 or above (newer) and you run the commands as they are shown above, an error message would appear and the estimation stops. The problem can be fixed by declaring the version number, version 10.1, in a specific way. Note that it has to be 10.1. How you should declare the version number depends on how you run Stata (non-interactive mode or interactive mode). Here we set out the appropriate solution, depending on which mode you are running Stata.
Non-interactive Mode (batch mode): In this mode you put all of the commands (three lines in this example) in a do-file, save it as (for example) myprogram.do in the current working directory, and run the program by typing do myprogram in Stata’s command window (and hitting the return key) or by choosing Tools->Execute (do) from the Do-file Editor’s command menu. This tells Stata to execute all of the commands in the do-file from the beginning to the end non-interactively.
Solution: If you run Stata in this mode, to avoid the version control problem, you have to put version 10.1 somewhere in your do-file (myprogram.do in this example) before the offending command occurs, and you only have to do it once in the file. A good place to put it would be at the beginning of the do-file. Continuing the example, the solution to your myprogram.do would be the following.
version 10.1
use mydata, clear
sfmodel y, production dist(h) frontier(x1 x2) usigmas(z1) vsigmas()
ml max, diff
Interactive Mode I (line-by-line): In this mode you type in the lines of commands, one at a time, into Stata’s Command window, and execute them one by one.
Solution: If you run Stata in this mode, then you have to type in and execute the line version 10.1 sometime in your session before the offending command occurs. Once it is declared, it remains valid until the session is closed (by shutting down Stata).
Interactive Mode II (block-by-block): In this mode you put all of the commands (three lines in this example) in a do-file, save it as, for example, myprogram.do in the current working directory. You then open this do-file using Stata’s Do-file Editor (Window -> Do-file Editor -> New Do-file Editor). You execute the commands by using the mouse to mark one or more lines in your do-file and hit the “Execute Selection (do)” button on the top right of the tool bar. This tells Stata to execute one or more lines of the commands together.
Solution: If you run Stata in this mode, then you have to include the line version 10.1 in the block that contains ml max, and you have to do it every time you execute ml max. In other words, version 10.1 and ml max have to be always executed together in the same block.