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   "Hauck, Katharina D" <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   RE: st: how to generate many dofiles in a program?
Date   Fri, 24 Jan 2014 13:55:12 +0000

Thanks Kit, works! I had the problem that ...

file write myfile "use "`data'/my_auto.dta", clear" _n

....did not work, but that was easily fixed by replacing with...

file write myfile `"use "`data'/my_auto.dta", clear"' _n

Katharina. 

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Christopher Baum
Sent: 19 January 2014 23:00
To: [email protected]
Subject: Re: st: how to generate many dofiles in a program?

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

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