Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: -merge- solution (was -joinby- problem)


From   "Clive Nicholas" <[email protected]>
To   [email protected]
Subject   st: -merge- solution (was -joinby- problem)
Date   Mon, 12 Apr 2004 21:53:13 +0100 (BST)

All,

On Friday, I posted this problem which now solved. It was to join this
data of wards (called london.dta)

>      +--------------------------------------------+
>      | pano   year   district        ward   votes |
>      |--------------------------------------------|
> 680. |    .     78    enfield       ARNOS    1394 |
> 681. |    .     82    enfield       ARNOS     493 |
> 682. |    .     82    enfield       ARNOS     536 |
> 683. |    .     86    enfield       ARNOS     545 |
> 684. |    .     86    enfield       ARNOS     534 |
>      |--------------------------------------------|
> 685. |    .     90    enfield       ARNOS     368 |
> 686. |    .     78    enfield       ARNOS     126 |
> 687. |    .     78    enfield       ARNOS     104 |
> 688. |    .     82   greenwic     ARSENAL     105 |
> 689. |    .     86   greenwic     ARSENAL      77 |
>      |--------------------------------------------|
> 690. |    .     78   greenwic     ARSENAL     555 |
> 691. |    .     82   greenwic     ARSENAL     641 |
> 692. |    .     86   greenwic     ARSENAL     685 |
> 693. |    .     90   greenwic     ARSENAL     575 |
> 694. |    .     78   greenwic     ARSENAL      85 |
>      |--------------------------------------------|
> 695. |    .     90   greenwic     ARSENAL     290 |
> 696. |    .     82   greenwic     ARSENAL     207 |
> 697. |    .     86   greenwic     ARSENAL     317 |
> 698. |    .     90   greenwic     ARSENAL      40 |
> 699. |    .     90   greenwic     ARSENAL     162 |
>      |--------------------------------------------|
> 700. |    .     78    croydon   ASHBURTON    2038 |
> 701. |    .     82    croydon   ASHBURTON    1818 |
> 702. |    .     86    croydon   ASHBURTON    1471 |
> 703. |    .     90    croydon   ASHBURTON    1640 |
> 704. |    .     78    croydon   ASHBURTON    1851 |
>      |--------------------------------------------|
> 705. |    .     82    croydon   ASHBURTON    1708 |
> 706. |    .     86    croydon   ASHBURTON    1338 |
> 707. |    .     90    croydon   ASHBURTON    1529 |
> 708. |    .     78    croydon   ASHBURTON     805 |
> 709. |    .     86    croydon   ASHBURTON     860 |
>      |--------------------------------------------|
> 710. |    .     90    croydon   ASHBURTON    1157 |
>      +--------------------------------------------+
>
> with this -reshape-d (long) list from another file (labels.dta)
>
>      +-------------------------+
>      | pano   year        ward |
>      |-------------------------|
>  73. |  238     78       ARNOS |
>  74. |  238     82       ARNOS |
>  75. |  238     86       ARNOS |
>  76. |  238     90       ARNOS |
>  77. |  284     78     ARSENAL |
>      |-------------------------|
>  78. |  284     82     ARSENAL |
>  79. |  284     86     ARSENAL |
>  80. |  284     90     ARSENAL |
>  81. |  169     78   ASHBURTON |
>  82. |  169     82   ASHBURTON |
>      |-------------------------|
>  83. |  169     86   ASHBURTON |
>  84. |  169     90   ASHBURTON |
>      +-------------------------+
>
> by each "pano" number. The objective was to insert the correct "pano"
> number into each "ward" entry for analysis by constituency.

I wanted to know if there a way of doing this without having to copy and
paste the data in _both_ files. Michael Blasnik privately gave me the
simple solution of

. merge ward year using labels.dta, update

I wasn't aware of this option on -merge-, but I was told that it is, after
all, detailed in -help merge-! My thanks to Michael and Nick Cox for their
private help on this.

CLIVE NICHOLAS        |t: 0(44)191 222 5969
Politics              |e: [email protected]
Newcastle University  |http://www.ncl.ac.uk/geps
*
*   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/



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