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 on April 23, and its replacement, statalist.org is already up and running.


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

st: -set obs- for -tempfile-


From   "Lythgoe, Dan" <D.Lythgoe@liverpool.ac.uk>
To   "'statalist@hsphsun2.harvard.edu'" <statalist@hsphsun2.harvard.edu>
Subject   st: -set obs- for -tempfile-
Date   Tue, 19 Feb 2013 12:27:20 +0000

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/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index