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

Greetings folks.
I faced such kind of problem, and can't find an appropriate solution for it. Hope community could help me.

I have two variables ` x and y.
x                         y
------------------------
0                        0
1                        1
2                        2
3                        3
4                        4
5                        5
Missing             Missing
Total                  Total

 

I need to create two new variables x_all and y_all, which will include all possible combinations of x and y variables.
e.g.

 

x_all           y_all

----------------------

0                   0

0                   1

0                   2

0                   3

0                   4

0                   5

0                   Missing

0                   Total

1                   .
.

.

.

Total             Total

---------------------------------

 

Hope there are some reasonable solutions for this problem.

Thank you in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
proc sql;
create table want as
select * from (select distinct x from have), (select distinct y from have);
quit;

Assuming your input data set is called HAVE and your desired data set is called WANT the above code should work. 

 


@webart999ARM wrote:

Greetings folks.
I faced such kind of problem, and can't find an appropriate solution for it. Hope community could help me.

I have two variables ` x and y.
x                         y
------------------------
0                        0
1                        1
2                        2
3                        3
4                        4
5                        5
Missing             Missing
Total                  Total

 

I need to create two new variables x_all and y_all, which will include all possible combinations of x and y variables.
e.g.

 

x_all           y_all

----------------------

0                   0

0                   1

0                   2

0                   3

0                   4

0                   5

0                   Missing

0                   Total

1                   .
.

.

.

Total             Total

---------------------------------

 

Hope there are some reasonable solutions for this problem.

Thank you in advance.


 

View solution in original post

2 REPLIES 2
Reeza
Super User
proc sql;
create table want as
select * from (select distinct x from have), (select distinct y from have);
quit;

Assuming your input data set is called HAVE and your desired data set is called WANT the above code should work. 

 


@webart999ARM wrote:

Greetings folks.
I faced such kind of problem, and can't find an appropriate solution for it. Hope community could help me.

I have two variables ` x and y.
x                         y
------------------------
0                        0
1                        1
2                        2
3                        3
4                        4
5                        5
Missing             Missing
Total                  Total

 

I need to create two new variables x_all and y_all, which will include all possible combinations of x and y variables.
e.g.

 

x_all           y_all

----------------------

0                   0

0                   1

0                   2

0                   3

0                   4

0                   5

0                   Missing

0                   Total

1                   .
.

.

.

Total             Total

---------------------------------

 

Hope there are some reasonable solutions for this problem.

Thank you in advance.


 

webart999ARM
Quartz | Level 8
Thank you for the quick response.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 2 replies
  • 886 views
  • 0 likes
  • 2 in conversation