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]

st: -set obs- for -tempfile-


From   "Lythgoe, Dan" <[email protected]>
To   "'[email protected]'" <[email protected]>
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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index