Dear Statalisters,
I'm clearly missing something when it comes to -tempfile- and I wonder if you can help. With a data set in memory I want to create a (very small) temporary data set where I can -set obs-, plot a simple graph and then restore the original data. Using a combination of -preserve- and -clear- works fine:
/****START****/
sysuse auto, clear
preserve
clear
set obs 12
gen x = _n
gen y = x^2
line y x
/****END****/
However I had anticipated that using -tempfile- would do the same but clearly -set obs- is not setting the number of observations for the temporary file but for the original file:
/****START****/
sysuse auto, clear
tempfile temp
set obs 12
gen x = _n
gen y = x^2
line y x
/****END****/
Returns the error:
obs must be between 74 and 2147483646
r(198);
Help would be greatly appreciated.
Many thanks
Dan Lythgoe
*
* 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/