Transcription of Stata: Software for Statistics and Data Science | Stata
{{id}} {{{paragraph}}}
merge datasetsDescriptionQuick startMenuSyntaxOptionsRemarks and examplesReferencesAlso seeDescriptionmergejoins corresponding observations from the dataset currently in memory (called the masterdataset) with those (called the using dataset), matching on one or more perform match merges (one-to-one, one-to-many, many-to-one, and many-to-many), which are often calledjoinsby database also perform sequential merges,which have no equivalent in the relational database for adding new variables from a second dataset to existing observations. You usemerge, for instance, when combining hospital patient and discharge datasets. If you wish to add newobservations to existing variables, then see [D]append. You useappend, for instance, when addingcurrent discharges to past link datasets in separate frames, you can use thefrlinkandfrgetcommands. Linking andmerging solve similar problems, and each is better than the other in some ways.
merge m:1 varlist ::: specifies a many-to-one match merge.. use discharges. merge m:1 hospitalid using hospitals would join the hospital data to the discharge data. This is an m:1 merge because hospitalid can correspond to many observations in the master dataset, but uniquely identifies individual observations in the using dataset.
Domain:
Source:
Link to this page:
Please notify us if you found a problem with this document:
{{id}} {{{paragraph}}}