MIDTERM: calling do-files from within other do-files

MIDTERM: calling do-files from within other do-files

by Amanda Irish -
Number of replies: 0

Hi all, it was brought to my attention today in lab that when using the command "run" as discussed in lecture for calling a do-file from within another do-file, it will suppress the output of that do-file whether or not you use the "quietly" option.

This means that when you "run" a do-file, it will not produce output for your log file. If you use the command log using <"output/your_log_name", replace>, then when you call that do-file with "run", Stata will write over your existing log file with a blank one. 

In order to have your output show up in your log files, you need to use a different command - the "do" command.

Sample code: 

do "do/your_do-file_name"

The other workarounds for this would be to:

1) not replace your log file - you can keep the command in your do-file but change it to:

capture log using "output/log_name"

Capture suppresses error messages and your code will run anyway (use capture judiciously - most of the time you want to see error messages!) Note: this ONLY WORKS IF you change the code AFTER you run through that do-file once to generate the log file.

2) Manually save the log file generated from your do-file under a different name (and make sure to turn in that version, of course!)

Let me know if any questions on this, and sorry for any confusion!