Statalist


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

st: using the first n observations in a dataset w/o evaluating the whole thing?


From   "Rodini, Mark" <mrodini@compasslexecon.com>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: using the first n observations in a dataset w/o evaluating the whole thing?
Date   Thu, 3 Apr 2008 16:31:58 -0700

Greetings.

Suppose I have a large Stata dataset (e.g. 3,000,000 observations) and I
only with to read in the first, say, 100 observations.

I have tried the code, which works:

use mydata if ( _N<100 )

However, evidently, this code goes through ALL 3 million observations to
evaluate the expression in parentheses, which can be very time consuming
(and sort of defeats the purpose).  Is there a way to only read the
first 100 observations without having to evaluate the entire dataset?

Perhaps some application of the "set obs 100"?  But I have not been
successful. 

Thank you.
-Mark

----------------------------------------------
Mark Rodini
mrodini@compasslexecon.com
 

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index