Daniel
Daniel

Reputation: 41

Combine two datasets without a common variable in SAS

Hi wanted to know how to combine the following example:

Data1

Groups
ABC 
FVC
HTR

Data2

Riders
H2
H3

Final or wanted table

Groups  RIDERS
ABC       H2
ABC       H3
FVC       H2
FVC       H3
HTR       H2
HTR       H3

Upvotes: 0

Views: 1613

Answers (2)

Llex
Llex

Reputation: 1770

It calls the cartesian product.

You can do it without cross join :

proc sql;
    select d1.groups, d2.riders
    from data1 d1,
         data2 d2;
quit;

Upvotes: 0

Gordon Linoff
Gordon Linoff

Reputation: 1269463

You are looking for a cross join. Using proc sql, this would be:

proc sql;
    select d1.groups, d2.riders
    from data1 d1 cross join
         data2 d2
    order by d1.groups d2.riders;
quit;

Upvotes: 2

Related Questions