Statalist


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

st: RE: Saving 1 observation


From   "Peter J. Burke" <[email protected]>
To   <[email protected]>
Subject   st: RE: Saving 1 observation
Date   Wed, 28 May 2008 17:25:28 -0700

Sergiy,
	Check out the ado file -savin- (findit savin)

STB-22  dm23  . . . . . . . . . . . .  Saving a subset of the current data
set
        (help savin if installed) . . . . . . . . . . . . . . . . . .  D.
Mabb
        11/94   p.6; STB Reprints Vol 4, pp.31--32
        save subset of the current dataset
Peter


Peter J. Burke
Professor of Sociology & Co-Director,
Social Psychology Research Laboratory (SPYRL)
University of California
Riverside, CA 92521-0419
Phone: 951/827-7004
��������������� 951/827-7119 (Spyrl Office)
Fax: 951/827-3330
[email protected]http://wat2146.ucr.edu/
http://sociology.ucr.edu/
http://sociology.ucr.edu/spyrl/index.html

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Sergiy Radyakin
Sent: Wednesday, May 28, 2008 3:32 PM
To: [email protected]
Subject: st: Saving 1 observation

Hello All!

I have a large dataset (to be specific ~ 1mln observations, 600MB).

I need to (repeatedly) save several small portions of it (small can be
as small as 1 observation) into separate files.

So far it is done similarly to this

preserve
  keep if Needed1
  save "Portion1"
restore

preserve
  keep if Needed2
  save "Portion2"
restore

... etc ...

where variables Needed1 and Needed2 are dummies generated earlier in the
code.

This works. But it is painfully slow.

The problem is that it will necessarily have to preserve/restore the
whole large dataset.
-save-  does not support -if- and -in- modifiers, otherwise my ideal
choice would be:

save "Portion1" if Needed1
save "Portion2" if Needed2

As an alternative I was thinking of saving the dataset directly (by
generating Stata file byte-by-byte), but since I need labels to be
preserved together with the data, this becomes more tricky, and
reinventing what is already [well] done, does not sound like a good
idea.

To pose a specific question: how to save one observation 1<=K<=_N
(with labels) to a Stata file, without having to save the whole
dataset?

Version of Stata: Stata 10/ Windows

Thank you,
    Sergiy Radyakin
*
*   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