Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

st: Is there a way and a seed reason to "double" preserve data?


From   Oliver Jones <ojones@wiwi.uni-bielefeld.de>
To   statalist@hsphsun2.harvard.edu
Subject   st: Is there a way and a seed reason to "double" preserve data?
Date   Mon, 04 Apr 2011 18:21:12 +0200

Hi all,

maybe the more important question is the one regarding the speed of
preserve restore vs. save use.
If it makes no difference then I can save my data and use it later.

But if there is a improvement in execution time by using preserve and
restore, then I would like know if there is a way to "double preserve"
my data?

I want to double preserve my data, to be able to make forecasts for
different individuals and then save the forecasts in a mata matrix.

In a two step forval construct I've got something like

*********** Begin example **************
sysuse xtline1, clear
bysort person: gen int t = _n
forval person = 1/3 {
	dis _n "Starting the analysis of Person `person'" _n
	
	preserve
	
	keep if person == `person'
	
	forval last_T = 360/365 { // here would follow the forecast code
		preserve
		egen mean_calories = mean(calories)
		keep in L/L
		lacal mean_person_`person'_days_`last_T' =  mean_calories[1]
		restore
	}
	restore
}
*********** end example **************

Kind regards
Oliver

--
Universität Bielefeld
Fakultät für Wirtschaftswissenschaften
Lehrstuhl für Ökonometrie und Statistik
- - -
Bielefeld University
Faculty of Business Administration and Economics
Chair of Econometrics and Statistics
- - -
Raum / room:  V9-110
Tel / phone:  +49 (0)521 106 4871
--
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index