Using NL in Stata

Once when running nonlinear least squares estimation in Stata, I received the following error:

unexpected end of file
nlCES returned 612
verify that nlCES is a function evaluator program

It turns out that a missing carriage return was causing the unexpected end of file. Linked here, you can download two .ado files and one .do file that should replicate the error. On Windows, put the two .ado files in your C:\ado\personal\ directory, then run the .do file from anywhere, allowing Stata to restart and notice the new .ado files.

.ado file 1
.ado file 2
.do file that calls the other two

This example is designed to work with Stata 9 and above, but it probably works with older versions of Stata, as long as you remove the "version 9" line from the .ado file.


Another time, it was this error message:

nlCES returned 198
verify that nlCES is a function evaluator program

It turned out that the subroutine was trying to read one too many scalar arguments, without a tempname declaration.

As before, here is an .ado file that has the problem, and a .do file that calls it:

.ado file
.do file that calls it

Back to links page