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]

RE: st: Saving datasets temporarily - switching back and forth between two datasets


From   "David Radwin" <[email protected]>
To   <[email protected]>
Subject   RE: st: Saving datasets temporarily - switching back and forth between two datasets
Date   Fri, 18 Nov 2011 14:40:51 -0800 (PST)

Ben,

You might also consider -preserve-ing the main dataset, refining the other
datasets, and -restore-ing the main dataset afterward.

David
--
David Radwin
Research Associate
MPR Associates, Inc.
2150 Shattuck Ave., Suite 800
Berkeley, CA 94704
Phone: 510-849-4942
Fax: 510-849-0794

www.mprinc.com


> -----Original Message-----
> From: [email protected] [mailto:owner-
> [email protected]] On Behalf Of Phil Clayton
> Sent: Friday, November 18, 2011 2:11 PM
> To: [email protected]
> Subject: Re: st: Saving datasets temporarily - switching back and forth
> between two datasets
> 
> Have you looked at -tempfile-? It allows you to save datasets to a
> temporary file from within a do-file. You don't need to specify the file
> name and they automatically get deleted.
> 
> So you could, for example, do something like this:
> use masterdataset
> (refine)
> tempfile master
> save `master'
> use usingdataset1
> (refine)
> tempfile using1
> save `using1'
> use usingdataset2
> (refine)
> tempfile using2
> save `using2'
> use `master'
> merge ...
> 
> You may also want to check out -mmerge- which is an extension to -merge-
> (available from SSC). It allows you to do things such as:
> - merge on a variable that has a different name in each dataset
> - rename variables from the "using" dataset on the fly
> - specify that you only want to merge in a subset of observations from
the
> "using" dataset
> 
> I often find that with -mmerge- I can accomplish what I need in one
> command, or occasionally two if I need to remove some duplicates after
> merging.
> 
> Phil
> 
> On 19/11/2011, at 8:54 AM, Ben Hoen wrote:
> 
> > I am executing a merge between one main dataset and a few others.
Some
> of
> > the other datasets need some additional refining before they can be
> merged
> > easily (e.g., changing variable names, culling out duplicates), but I
> have
> > no need to save off these temporary versions.
> >
> > Is it possible to hold the main dataset in "memory" while I quickly
> refine a
> > using dataset, then save IT into memory, from where I perform the
merge?
> >
> > Tangentially, if I was to save off a temporary file to merge to, can I
> erase
> > that file from a do-file?
> >
> > Did that make sense?
> >
> > Ben
> >
> > Ben Hoen
> > Principal Research Associate
> > Lawrence Berkeley National Laboratory
> > Office: 845-758-1896
> > Cell: 718-812-7589
> > [email protected]
> > http://eetd.lbl.gov/ea/emp/staff/hoen.html

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index