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.
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.
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.
It's your turn to help shape SAS Innovate 2027. Share your expertise and inspire the SAS community.
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.
Ready to level-up your skills? Choose your own adventure.