BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Pcase
Calcite | Level 5

Normally I merge datasets using a key.  However, in this case I don't have or want a key.  I want to get a new dataset that combines each row from both.  Here's an example with two datasets:

 

Data1:

Fld1:

A

B

 

Data2:

Fld2:

1

2

3

 

I want to get:

Data3:

Fld1: Fld2:

A       1

A       2

A       3

B       1

B       2

B       3

 

How do I achieve this?  Nothing I've tried so far has worked Thanks!

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

"All combinations" is a simple task for SQL:

proc sql;
   create table data3 as select * from data1, data2;
quit;

 

View solution in original post

3 REPLIES 3
Astounding
PROC Star

"All combinations" is a simple task for SQL:

proc sql;
   create table data3 as select * from data1, data2;
quit;

 

Pcase
Calcite | Level 5

Thanks!  This did the trick!

SASKiwi
PROC Star

DATA step method:

data A;
  var1 = 'A'; output;
  var1 = 'B'; output;
run;

data B;
  var2 = 1; output;
  var2 = 2; output;
  var2 = 3; output;
run;

data c;
  set A;
  do i = 1 to OBSNUM;
    set B point = i nobs = OBSNUM;
    output;
  end;
run;

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 854 views
  • 2 likes
  • 3 in conversation