BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.

Hi all,

 

I have a dataset of ds1.

data ds1;
infile datalines;
input name1 $ name2 $;
datalines;
G A
A B
I C
B D
;
RUN;

 

I need output like 

NAME1 NAME2
G A
A A
I A
B A
G B
A B
I B
B B
G C
A C
I C
B C
G D
A D
I D
B D

 

I follow in proc sql cartesian join but this output not getting.

Can anyone suggest how it can be done.

Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
Ravikumarkummari
Quartz | Level 8

proc sql;
create table ds_final as
select a.name2, b.name1 from ds1 a cross join ds1 b ;
quit;

 

 

 

Solved thank u

Actually i not mentioning the variables and follow cross join.

select * from ds1 cross join ds1;

 

 

View solution in original post

3 REPLIES 3
Reeza
Super User

A cartesian join is correct. Post your code/log and explain how it does not match your desired output. 

Ravikumarkummari
Quartz | Level 8

proc sql;
create table ds_final as
select a.name2, b.name1 from ds1 a cross join ds1 b ;
quit;

 

 

 

Solved thank u

Actually i not mentioning the variables and follow cross join.

select * from ds1 cross join ds1;

 

 

Ksharp
Super User
data ds1;
infile datalines;
input name1 $ name2 $;
datalines;
G A
A B
I C
B D
;
RUN;
proc sql;
select *
 from ds1(keep=name1),ds1(keep=name2) order by 2;
quit;

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 741 views
  • 0 likes
  • 3 in conversation