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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.