[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: simple "merge" question

From   Neil Shephard <>
Subject   Re: st: simple "merge" question
Date   Mon, 9 Mar 2009 12:33:45 +0000

On Mon, Mar 9, 2009 at 12:06 PM,  <> wrote:
> Hello,
> I have two datasets: the first one, called "country" gives some
> characteristics of 221 countries (GDP, population...), the second one,
> called "safety", contains 24 countries with the variable "safety public
> expenditures"
> I want to merge these databases, by keeping all the countries. So I write:
> ...........
> use base_pays\country.dta, clear
> sort country
> merge country using GFS\safety
> sort _merge
> ......
> The problem is that Stata accepts to merge (I have no error message), but
> indeed my datasets are not merged: the common countries are repeated two
> times, and _merge just takes values 1 and 2. So I really don't know what
> to do.

The -man merge- page informs you what the various values _merge can
take and what they signify (which in turn points to the source of your

But in summary it means that whilst you have the same variable name in
both data sets for merging them (the variable 'country') there are no
values in either file which are common to both data sets, hence you
get no matches.

This could be down to captilisation in one file and not the other, or
unwanted spaces in values, or that there genuinely isn't anything in
base_pays\country.dta dataset that matches GFS\safety.dta

Thus, the starting point is to ensure that the values for country in
your GFS/safety.dta file match the corresponding entries in
base_pays/country.dta.  You can do this using either -tabulate oneway-
or -levelsof-


"The combination of some data and an aching desire for an answer does
not ensure that a reasonable answer can be extracted from a given body
of data." ~ John Tukey (1986), "Sunset salvo". The American
Statistician 40(1).

Email -
Website -
Photos -
*   For searches and help try:

© Copyright 1996–2021 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index