In accordance with recommendations from a NetCourse taken some time ago, I'm
writing a master do-file that calls dataset-creating do-files and then calls
analysis do-files to act upon the datasets created.
I would like to use temporary files (-tempfile-) for the analysis datasets that
are shared. So, I create a global macro to hold the physical file name in
order to pass the tempfile to the called do-files so that it can be shared
between the dataset-creating and analysis do-files. (Illustrated below.)
Question: is this the recommended approach to sharing tempfiles among
do-files?
Joseph Coveney
--------------------------master.do--------------------------------------------
tempfile tmp1 tmp2 tmp3 tmp4
forvalues fileno = 1/4 {
save `tmp`fileno'', emptyok
global crtmp`fileno' : display "`tmp`fileno''"
}
do cr1
do cr2
[etc.]
do an1
do an2
[etc.]
exit
---------------------------cr1.do----------------------------------------------
odbc load [. . .]
[manipulations to create analysis dataset]
save "$crtmp1", replace
exit
---------------------------an1.do----------------------------------------------
use "$crtmp1", clear
tabulate [. . .]
summarize [. . .]
[etc.]
exit
--------------------------------------------------------------------------------
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/