Hi Charles
A bit a more specific question - eventually with sample data and expected result - would help us to understand your question better and give you a more adequate answer.
There is quite a bit of docu available in regards of combining SAS datasets and Proc SQL. Below a few links and some example code:
Combining SAS datasets:
http://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#a001125856.htm
http://support.sas.com/documentation/cdl/en/basess/58133/HTML/default/a001293108.htm#
Proc SQL:
http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a000086336.htm
http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a002473691.htm (SQL joining tables)
data have1;
do key1=1,3,5;
do key2=2,4;
var='Have 1';
output;
output;
end;
end;
run;
data have2;
do key1=1,5;
do key2=2;
var='Have 2';
output;
output;
end;
end;
run;
title1 'Inner Join 1: Many to Many';
proc sql;
select
l.key1 as l_key1
, l.key2 as l_key2
, l.var as l_var
, r.key1 as r_key1
, r.key2 as r_key2
, r.var as r_var
from have1 l,have2 r
where l.key1=r.key1 and l.key2=r.key2
;
quit;
run;
title1 'Inner Join 2: Many to Many';
proc sql;
select
l.key1 as l_key1
, l.key2 as l_key2
, l.var as l_var
, r.key1 as r_key1
, r.key2 as r_key2
, r.var as r_var
from have1 l inner join have2 r
on l.key1=r.key1 and l.key2=r.key2
;
quit;
run;
title1 'Left Join: Many to Many';
proc sql;
select
l.key1 as l_key1
, l.key2 as l_key2
, l.var as l_var
, r.key1 as r_key1
, r.key2 as r_key2
, r.var as r_var
from have1 l left join have2 r
on l.key1=r.key1 and l.key2=r.key2
;
quit;
run;
title1 'Right Join: Many to Many';
proc sql;
select
l.key1 as l_key1
, l.key2 as l_key2
, l.var as l_var
, r.key1 as r_key1
, r.key2 as r_key2
, r.var as r_var
from have1 l right join have2 r
on l.key1=r.key1 and l.key2=r.key2
;
quit;
run;
title1 'Outer Join: Many to Many';
proc sql;
select
l.key1 as l_key1
, l.key2 as l_key2
, l.var as l_var
, r.key1 as r_key1
, r.key2 as r_key2
, r.var as r_var
from have1 l full outer join have2 r
on l.key1=r.key1 and l.key2=r.key2
;
quit;
run;
title1 'Union Join: Many to Many';
proc sql;
select *
from have1
union
select *
from have2
;
quit;
run;
title1 'Outer Union Join: Many to Many';
proc sql;
select *
from have1
outer union
select *
from have2
;
quit;
run;
title1 'Outer Union Corr Join: Many to Many';
proc sql;
select *
from have1
outer union Corr
select *
from have2
;
quit;
run;
HTH
Patrick
Message was edited by: Patrick