Statalist


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

st: Merge two datasets by more than one variable


From   Thomas Cars <[email protected]>
To   [email protected]
Subject   st: Merge two datasets by more than one variable
Date   Thu, 02 Jul 2009 13:49:59 +0200

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/



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