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]

Re: st: how to generate many dofiles in a program?


From   Christopher Baum <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: how to generate many dofiles in a program?
Date   Sun, 19 Jan 2014 23:00:04 +0000

<>
Katharina wrote

I want to generate 300 STATA do-files in a program, varying two macros for
each of the separate do-files.  There is a thread on that issue, and
apparently the file write command can be used to created STATA do-files in
a program, but it is not clear to me how exactly to do that.
 
As background: I need to run a very computationally intensive job on a
high performance computer in parallel. I run a regression repeatedly with
varying combinations of regressors, and save the results. I want to split
the job in 300 separate batches, and per batch, I want to run 1000
regressions.  In need to vary for each do-file the set of regressors (I
use the tuples ado from Nick Cox).  Our HPC does not accept the user
written parallel programming ado, so I need to farm this out myself, and I
see no other solution but to create 300 do-files from one master do-file,
changing the range of tuples to be estimated in each of the 300 files.


Something like

sysuse auto, clear
tuples headroom-turn
loc nt `ntuples'
forv i=1/`nt' {
	file open myfile using tuple`i'.do, write replace
	file write myfile "sysuse auto" _n
	file write myfile "reg price `tuple`i''" _n
	file write myfile "exit, clear" _n
	file close myfile
}



Kit Baum
Professor of Economics and Social Work, Boston College, Chestnut Hill MA, USA
DIW Research Professor, Department of Macroeconomics, DIW Berlin, Berlin, Germany
[email protected]  |  http://ideas.repec.org/e/pba1.html












*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


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