Thanks to Kit Baum, a new version of the -addinby- package is now available for download from SSC. In Stata, use the -ssc- command to do this, or -adoupdate- if you have an existing version of -addinby-.
The -addinby- package is described as below on my website. The new version has been updated to Stata Version 11, so it is now a cleaner version of -merge m:1-, instead of being a cleaner version of -merge-, as in Stata Version 10. The new version also adds a new option -generate()-, allowing the user optionally to generate a match results variable, although this variable is not generated by default. Also, the -using- dataset no longer has to be sorted by its foreign key, although that foreign key must uniquely identify its observations.
Users of Stata Version 10 can still download the Stata 10 version of -addinby- from my website by typing, in Stata,
net describe addinby, from(http://www.imperial.ac.uk/nhli/r.newson/stata10)
and then installing.
The -addinby- package is used, together with the SSC package -keyby-, to enforce the relational database model, in which a dataset is viewed as a mathematical function, whose domain is the set of available combinations of its key variable values, and whose range is the set of all possible combinations of its non-key variable values. Life is a lot simpler if you can always assume that about a dataset.
Best wishes
Roger
Roger B Newson BSc MSc DPhil
Lecturer in Medical Statistics
Respiratory Epidemiology and Public Health Group
National Heart and Lung Institute
Imperial College London
Royal Brompton Campus
Room 33, Emmanuel Kaye Building
1B Manresa Road
London SW3 6LR
UNITED KINGDOM
Tel: +44 (0)20 7352 8121 ext 3381
Fax: +44 (0)20 7351 8322
Email: [email protected]
Web page: http://www.imperial.ac.uk/nhli/r.newson/
Departmental Web page:
http://www1.imperial.ac.uk/medicine/about/divisions/nhli/respiration/popgenetics/reph/
Opinions expressed are those of the author, not of the institution.
---------------------------------------------------------------------------
package addinby from http://www.imperial.ac.uk/nhli/r.newson/stata11
---------------------------------------------------------------------------
TITLE
addinby: Add in data from a disk dataset using a foreign key
DESCRIPTION/AUTHOR(S)
addinby is a "cleaner" alternative version of merge m:1, designed to
reduce the lines of code in Stata do-files. It adds variables
and/or values to existing observations in the dataset currently in
memory (the master dataset) from a Stata-format dataset stored in
the file filename (the using dataset), using a foreign key of
variables specified by the keyvarlist to identify observations in
the using dataset. These foreign key variables must identify
observations in the using dataset uniquely. Unlike merge m:1,
addinby always preserves the observations in the master dataset in
their original sorting order, and never adds any additional
observations, and only generates a matching information variable if
requested to do so. However, addinby may optionally check that
there are no unmatched observations in the master dataset, and/or
check that there are no missing values in the foreign key variables
in the master dataset.
Author: Roger Newson
Distribution-Date: 17september2009
Stata-Version: 11
INSTALLATION FILES (click here to install)
addinby.ado
addinby.sthlp
---------------------------------------------------------------------------
(click here to return to the previous screen)
*
* 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/