It's necessary to remember that proc sql first do the Carditian product and then select obs based on the conditions.
For example, the following code: a.a 1 has 3 replicates, 2 has 2 replicates, b.a is unique, c.a 2 has 3 replicates and 3 has 3 replicates, so totally 1 will have 3*1*1=3 replicates, 2 has 2*1*3=6 replicates, 3 will have 1*1*3=3 replicates. if no other conditions, then totally there will be 3+6+3=12 observations.
data a;
input a b;
cards;
1 2
1 3
1 5
2 3
2 7
3 5
;
run;
data b;
input a c;
cards;
1 2
2 3
3 5
;
run;
data c;
input a d;
cards;
1 1
2 1
2 2
2 3
3 1
3 2
3 3
;
run;
proc sql;
create table test as
select a.*, b.c, c.d
from a,b,c
where a.a=b.a and b.a=c.a;
quit;
proc print data=test;
run;
The output is:
Obs a b c d
1 1 2 2 1
2 1 3 2 1
3 1 5 2 1
4 2 3 3 1
5 2 3 3 3
6 2 3 3 2
7 2 7 3 1
8 2 7 3 3
9 2 7 3 2
10 3 5 5 1
11 3 5 5 3
12 3 5 5 2