Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: Mergeing datasets


From   Alan Neustadtl <[email protected]>
To   [email protected]
Subject   Re: st: Mergeing datasets
Date   Tue, 26 Apr 2011 18:56:02 -0400

Would -stack- get you closer to your solution?  Are you trying to make
a single variable with id numbers and merge in new data?  The
following might be what you want:

capture clear *
input   int (master   id1   id2   id3   id4)
      106   708   673     .   676
      110   713   696     .   704
      122   721   721     .     .
      123   749   722     .   728
      129   789   789   734     .
      134   739   739     .     .
      144   800   752     .   763
      145   808   753     .   780
      151   797   764     .   781
      158   811   771     .   779
end

stack  id1 id2 id3 id4, into(masterid) clear
list

And then, maybe -reshape- back to your original format.

Best,
Alan

On Tue, Apr 26, 2011 at 6:17 PM, Thomas Speidel <[email protected]> wrote:
>    master   id1   id2   id3   id4
>       106   708   673     .   676
>       110   713   696     .   704
>       122   721   721     .     .
>       123   749   722     .   728
>       129   789   789   734     .
>       134   739   739     .     .
>       144   800   752     .   763
>       145   808   753     .   780
>       151   797   764     .   781
>       158   811   771     .   779
>
> I have a working dataset containg id.  The id may come from id1, id2, id3,
> or id4 above:
>
> . list id in 1/10, clean noobs
>
>      id
>    2014
>    2030
>    2038
>    2041
>    2042
>    2054
>    2055
>    2058
>    2061
>    2065
>
> I need to merge(?) the two so that I can get the master id for each id,
> regardless of whether they came from id1 id2 id3 id4.
> I thought this was a job for merge, but did not find a mention for this type
> of situations in the manual.  I suppose I could do four sequential merges.
>  Any suggestion on how to best proceed?
> Thanks.
>
> --
> Thomas Speidel
> *
> *   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/
>

*
*   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index