Roger has described the situation very accurately.
Users now have a choice.
My -savesome- attempts to follow a principle made
explicit in "Suggestions on Stata programming style",
a document that is stylerules.hlp on SSC, and will
appear in expanded form in Stata Journal 5(4) 2005
later this month, that programs should, on
the whole, attempt to do just one thing well.
The process of attempting to -save- some of the
data is a single task. Roger is quite correct that
when producing a new dataset a user may want to
do other things as well, and his program offers
scope for renaming and sorting on the fly.
Of these, renaming can be a little tricky, and
moreover there are lots of ways one might want to rename.
My own advice is to get into a new dataset
first, and then rename. The -renvars- program
of Weesie and Cox is one way to do that,
with several handles.
But, as said, users have a choice.
As I understand Roger's program, it will fail
if the -rename()- is problematic, and so
users are safe.
Nick
[email protected]
Roger Newson
> Thanks to Kit Baum, a new package -subsave- is now available
> for download
> from SSC. In Stata, use the -ssc- command to do this.
>
> -subsave- is described as below on my website. It is similar to Nick
> Cox's -savesome-, which I discovered just after writing
> -subsave-, and which
> is also on SSC. However, -subsave- has 2 extra options, -rename()-
> and -gsort()-, allowing users to rename variables and to
> resort observations in the output dataset.
>
> --------------------------------------------------------------
> --------------
> ----
> package subsave from http://www.kcl-phs.org.uk/rogernewson/stata9
> --------------------------------------------------------------
> --------------
> ----
>
> TITLE
> subsave: Save a subset of the dataset in memory to a disk file
>
> DESCRIPTION/AUTHOR(S)
> subsave saves a subset of the dataset currently in
> memory to a disk
> file. This saves the user the trouble of inserting a preserve
> statement before a save command and a restore statement
> after a save
> command. This is especially useful in a group of
> commands between a
> preserve command and a restore command, as paired
> preserve and restore
> statements cannot be nested. In the output dataset,
> variables can be
> renamed, and observations can be resorted.
>
> Author: Roger Newson
> Distribution-date: 30November2005
> Stata-version: 9
>
>
> INSTALLATION FILES (click
> here to install)
> subsave.ado
> subsave.hlp
> --------------------------------------------------------------
*
* 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/