There's some minor confusion here. I didn't recommend fixing your loop with -capture-, as there is no need to write a loop in the first place.
More specifically, it's not a case of anybody's preference for return codes. The return codes to work with are those that a command might return. In many cases, the return code is 0 if something works and some non-zero code if it doesn't, and the programmer can work on that basis.
Nick
[email protected]
Hua Pan
Thank you very much for your help.
Michael, your command is great, very effective. That’s exactly what I want and failed to find. Thank you indeed.
Martin and Nick, Thank you for your suggestions. After I added “capture” before “by”, the loop continued to work, and I also got the daily mean return for all firms with this complicate method. After I typed,
-di in red _rc-
the return code was 198. Does that mean that this code is wrong? Error (198)
When I put “capture” before “by” and “save”, the loop also continued to work and I got what I want, but this time the return code was zero.
“Capture” is really useful, that can help me a lot later, so I want to know why there are different return codes and which one should I prefer? Thanks a lot in advance.
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/