Statalist


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

AW: st: Merge two datasets by more than one variable


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   AW: st: Merge two datasets by more than one variable
Date   Thu, 2 Jul 2009 14:23:37 +0200

<> 


W/o quotes around "Salicylic Acid", the "Acid" will get chopped...



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Tirthankar Chakravarty
Gesendet: Donnerstag, 2. Juli 2009 13:59
An: statalist@hsphsun2.harvard.edu
Betreff: Re: st: Merge two datasets by more than one variable

<>
<>
***** begin
clear*
input id      document_id     row_number      str15 Drug
1       35               1               Metoprolol
1       35               2               Atenolol
1       35               3               Bisoprolol
2       12               1               Salicylic Acid
2       12               2               Remicade
3       11               1               Folic Acid
3       11               2               Enalapril
3       11               3               Metoprolol
end
sort id document_id row_number
save dataset1, replace
clear
*****
input id      document_id     row_number   date  str10  Time
1       35               1               080101  12.10
1       35               2               080201  13.10
1       35               3               080301   14.00
2       12               1               080101   12.20
2       12               2               080401   13.10
3       11               1               080501   15.10
3       11               2               080601   16.00
3       11               3               080601   17.10
end
sort id document_id row_number
save dataset2, replace

*****
merge id document_id row_number using dataset1
list, clean
***** end


On Thu, Jul 2, 2009 at 12:49 PM, Thomas Cars<thomas.cars@pubcare.uu.se> wrote:
> Hi,
> I would like to merge two datasets by three variables:
>
> Example:
>
> Dataset1:
>
> Id      document-id     row-number      date    Time
> 1       35               1               080101  12.10
> 1       35               2               080201  13.10
> 1       35               3               080301   14.00
> 2       12               1               080101   12.20
> 2       12               2               080401   13.10
> 3       11               1               080501   15.10
> 3       11               2               080601   16.00
> 3       11               3               080601   17.10
>
>
> Dataset2:
> ID      document-id     row-number      Drug
> 1       35               1               Metoprolol
> 1       35               2               Atenolol
> 1       35               3               Bisoprolol
> 2       12               1               Salicylic Acid
> 2       12               2               Remicade
> 3       11               1               Folic Acid
> 3       11               2               Enalapril
> 3       11               3               Metoprolol
>
>
> I would now like to combine the two datasets above with the result:
>
> Id      document-id     row-number      date    Time         Drugs
> 1       35               1               080101  12.10        Metoprolol
> 1       35               2               080201  13.10        Atenolol
> 1       35               3               080301  14.00        Bisoprolol
> 2       12               1               080101   12.20        SalicylAcid
> 2       12               2               080401   13.10        Remicade
> 3       11               1               080501   15.10        Folic Acid
> 3       11               2               080601   16.00        Enalapril
> 3       11               3               080601  17.10        Metoprolol
>
>
> Is it possible to do a merge like: merge pat document-id
> rownumber using dataset2?
>
> Hope anyone can help me?
> Thomas
>
>
>
>
>
> *
> *   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/
>



-- 
To every ω-consistent recursive class κ of formulae there correspond
recursive class signs r, such that neither v Gen r nor Neg(v Gen r)
belongs to Flg(κ) (where v is the free variable of r).

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index