Statalist


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

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


From   "Kieran McCaul" <[email protected]>
To   <[email protected]>
Subject   st: RE: using the first n observations in a dataset w/o evaluating the whole thing?
Date   Fri, 4 Apr 2008 07:54:44 +0800

Try:
use in 1/100 using mydata, clear

______________________________________________
Kieran McCaul MPH PhD
WA Centre for Health & Ageing (M573)
University of Western Australia
Level 6, Ainslie House
48 Murray St
Perth 6000
Phone: (08) 9224-2140
Phone: -61-8-9224-2140
email: [email protected]
http://myprofile.cos.com/mccaul 
_______________________________________________


-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Rodini, Mark
Sent: Friday, 4 April 2008 7:32 AM
To: [email protected]
Subject: st: using the first n observations in a dataset w/o evaluating
the whole thing?

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
[email protected]
 

*
*   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/



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