Thanks!
Thomas
-----Ursprungligt meddelande-----
Från: [email protected] [mailto:[email protected]] För Tirthankar Chakravarty
Skickat: den 2 juli 2009 13:59
Till: [email protected]
Ämne: 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<[email protected]> 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/