Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: How to save current status of Stata (eg. contents of macros, matrix and data)?


From   Andreas Peichl <[email protected]>
To   [email protected]
Subject   st: How to save current status of Stata (eg. contents of macros, matrix and data)?
Date   Tue, 13 May 2008 18:56:51 +0200

Dear Statalisters,

(sorry for a possible double posting, but it seems to we that my first message
did not go through to the list, and now including a subject line)

I'm using Stata to call a program written in C++ to execute some simulations.
One run of this program takes about 15 min. I'm using several nested foreach
and forvalue loops to simulate different scenarios and to bootstrap the results
which I save in a matrix. The whole program runs for about a week. As this is a
quite time consuming exercise, I'm quite vulnerable to system crashes. I'm
therefore looking for a way to save the whole content of the Stata memory
(data, macros, matrix) to the hard disk which could then be restored if the
system crashes and I could restart at this point. (It would be something like
-preserve- and -restore- but not only for data).

Searching the Statalist archive, I came across this thread:
http://www.stata.com/statalist/archive/2005-01/msg00688.html

Using these programs to save the contents of the globals and locals together
with -save- and -svmat-, I was thinking of writing a "savetoHD" (and
readfromHD) command. I could then write my program in the following way (using
pseudo code):

readfromHD (x, start, end)    // read in parameters from previous run, x is last
                                 element used in loop
local start = `x'                     // set starting value of this loop to this
                                         last element
forval x = `start'/`end' {        // start loop
savetoHD                           // save parameters
simulation , ...
save results
}

(My problem is somewhat more complicated as I have nested loops but in principle
it should work this way).

Does anybody know a better way (or even a command) of how to achieve this
"preserve-restore" procedure? Any suggestions are warmly welcome.

Many thanks,
Andreas

_____________________
Dr. Andreas Peichl
Universit�t zu K�ln
Seminar f�r Finanzwissenschaft, Lehrstuhl Prof. Dr. C. Fuest
Albertus-Magnus-Platz | 50923 K�ln
Tel: +49(0)221-470-6201 | Fax: +49(0)221-470-5060
Mail:  [email protected] | URL: http://www.wiso.uni-koeln.de/fuest
http://www.wiso.uni-koeln.de/ASPSamp/fuest/home/index.asp?l=15&wh=peichl.asp&ID_mitarbeiter=6
*
*   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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index