Quantcast
Channel: Statalist
Viewing all articles
Browse latest Browse all 73288

program end leads to stata breaking?

$
0
0
Hi Statalist,

I am having difficulty fixing this particular (probably syntactic?) error and would appreciate another pair of eyes looking at it.

I want to define a program inside a forvalues loop. I've written a simpler version of what I want here:
Code:
forvalues i = 1 / 12 {
    di "`i'"

    cap prog drop aaa
    prog def aaa
        di "hello `i'"
    end 
}
When I run this (STATA/MP 15.1 on windows 10), I receive the following error message:

Code:
--Break--
r(1);

end of do-file

--Break--
r(1);
Oddly, the `i' that should display at the beginning of the loop never displays itself, unless I remove the end command like this:
Code:
forvalues i = 1 / 12 {
    di "`i'"

    cap prog drop aaa
    prog def aaa
        di "hello `i'"
   * end 
}
In this latter case, `i' displays for the first loop before I get the error message you would expect, telling me I never finished defining my program:
Code:
1
  1. 
unexpected end of file
r(612);

end of do-file

r(612);
Thank you for the help!

Julian


Viewing all articles
Browse latest Browse all 73288

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>