Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: RE: Using macros and batch running.


From   "Adrian Sayers" <[email protected]>
To   <[email protected]>
Subject   st: RE: Using macros and batch running.
Date   Mon, 4 Jul 2011 12:17:16 +0100

Hi Daniel,

I had thought of righting a header file. (i.e. .doh) but i am not sure this
will solve my problem. I should probably explain what i am trying to do
better. 

Currently i am running series of simulations, which take 3+ days to complete
on my PC.

Most of the process are serial, therefore their is limited gains in
parrelisation. However i had hoped that i could invoke stata in numerous
windows, this would allow me to perform all experiments in the simulation
simultaneously, drastically cutting the running time from 3 days to 20
minutes.

To do this i need to modify do files on the fly, so to speak. Typically if
you were running this on only 1 machine i would bundle this in a loop and
just wait for it to run serially. 

My second attempt is to write a do file, which in turns writes all my other
do files. 

But this is not pretty, or very elegant. 
Hopefully this will give you a better idea of what i am trying to achieve.

Cheers
Adrian

E.g.
****************************************************************************
**
* Create the do files in code... Basically Prefixing all code with display
foreach i in 1  2 3 {
cap log close
qui log using test`i'.do  , text replace
di "clear all                         "
di "set obs 1000                      "
di "gen id = _n                       "
di "gen x = `i'*uniform()             "
di "save testdata`i' , replace        "


qui log close
}

* execute batch created do files using the batch function.
forvalues i = 1/3 {
winexec "\\mypath\stata11\StataMP.exe" -e include test`i'.do
} 

****************************************************************************
****

*
*   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index