[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
Re: st: Merging 2 datasets with different setting
From
"Marc N. Sch�ssler" <[email protected]>
To
[email protected]
Subject
Re: st: Merging 2 datasets with different setting
Date
Fri, 26 Sep 2008 09:01:26 +0200
Hi Aca,
As far as i know there is no other way then using the -reshape
wide- command to your Data set#2 before merging.
hope this helps
Marc
Am 26.09.2008 um 05:33 schrieb Aca N.T.:
Hi,
I got 2 prepared data sets which were constructed differently, the
first one goes like other standard data set assigning each observation
in one row. The other contains drugs data which was set vertically so
for each observation there may be several records put downwardly. The
primary key for linkage is ID and they appear like below:
Data set #1
id age disease
1 23 0
2 32 1
3 28 1
4 27 0
Data set #2
id drug
1 A1
1 B2
1 C1
2 B2
2 B3
3 A1
3 B3
I wonder if there is a quick way to merge the two so that each
observation come in one row. This may involve creating either nominal
variables for each drug at alphanumeric level (A1, A2, B1, B2) or
count variables at alpha level (A/B/C) - so should look like this:
id age disease A1 A2 B1 B2
B3 C1 drugA drugB drugC
1 23 0 1 0 0
1 0 1 1 1 1
2 32 1 0 0 0
1 1 0 0 2 0
3 28 1 1 0 0
0 1 0 1 1 0
Thank you,
Aca
*
* 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–2024 StataCorp LLC | Terms of use | Privacy | Contact us | What's new | Site index |