Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

Re: st: Merge question


From   Nick Cox <njcoxstata@gmail.com>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   Re: st: Merge question
Date   Wed, 15 May 2013 21:00:38 +0100

Check for trailing spaces and for char 160 (looks like a space, but isn't).

replace county = subinstr(county, "`= char(160)'", " ", .)

-charlist- from SSC may help.

Nick
njcoxstata@gmail.com


On 15 May 2013 20:53, Michael Betz <betz.40@buckeyemail.osu.edu> wrote:
> Hi all--I'm having a confusing merge issue. I'm merging on string variables "state" and "county". It works for 99% of the observations, but is having trouble with the counties that begin with "ST". As you can see below, there are what appear to be identical observations that are categorized as "using only" or "master only", though they should be matched. I can't figure out what is stopping them from merging. If I execute count if county=="ST CLAIR", Stata only returns 4, when I would expect 8. Here is my code and part of the resulting merged dataset:
>
> merge 1:1 state county using "stco fips"
>
> county          state   totaloasdi      disabledworkers fipsstate
> ST CHARLES      MO                      29      183     using only (2)
> ST CHARLES      LA                      22      089     using only (2)
> ST CLAIR        IL                      17      163     using only (2)
> ST CLAIR        MI                      26      147     using only (2)
> ST CLAIR        MO                      29      185     using only (2)
> ST CLAIR        AL                      01      115     using only (2)
> ST CROIX        WI                      55      109     using only (2)
> ST FRANCIS      AR                      05      123     using only (2)
> ST FRANCOIS     MO                      29      187     using only (2)
> ST CHARLES      LA      6317    795                     master only (1)
> ST CHARLES      MO      35290   3645                    master only (1)
> ST CLAIR        AL      10905   1810                    master only (1)
> ST CLAIR        IL      43120   4965                    master only (1)
> ST CLAIR        MO      2721    410                     master only (1)
> ST CLAIR        MI      27015   2870                    master only (1)
> ST CROIX        VI      6879    670                     master only (1)
> ST FRANCIS      AR      5146    735                     master only (1)
> ST FRANCOIS     MO      12406   2040                    master only (1)
>
> Thanks,
> Mike
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/statalist-faq/
> *   http://www.ats.ucla.edu/stat/stata/

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


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index