|
alves wrote:
> Hi guys.
>
> Need to make a stange merge, and having some problems how to do it (at
> least with datasteps).
>
> I have 2 datasets (treatment and no-treatment) and I need to merge the
> datasets in a way that each observation in the treatment dataset will
> be merged with all no-treatment patients with the same age. some
> treatments patients have the same age and when the age repeats I need
> again all no-treatment patients.
>
> Datasets are pretty big so I trying to find a way that optimises
> speed.
Have you reached some bottleneck or case where a current method takes "too
long".
How big is big?
- How many rows and columns in each table?
- Does one table consistently have more rows than the other ?
Are the tables indexed?
What have you tried, if anything?
Was it anything like a left join?
----------------------------------
data one(index=(focus1=(id1 id2) age));
input id1 $ id2 $ age;
cards;
a xx 25
a yy 30
c tt 25
d tt 35
e zz 40
run;
data two (index=(id age));
input id age;
cards;
1 25
2 25
3 30
4 35
5 35
6 25
7 25
8 30
run;
options msglevel=I;
proc sql;
create table three as
select one.*, two.id
from
one
left join
two
on
one.age = two.age
order by
id1, id2, id
;
quit;
----------------------------------
There are many other ways to join data.
Richard A. DeVenezia
http://www.devenezia.com/
|