Hello All,
Good evening.
I am working on a code in which I have to reproduce all observations in loop (max iteration of loop will be decided by number of observations) in such a way that each variable value is reproduced against all values and so on.
have
Apple
Orange
Banana
Want
Apple, Apple
Apple, Orange
Apple, Banana
Orange, Apple
Orange, Orange
Orange, Banana
Banana,Apple
Banana, Orange
Banana, Banana
The number of observations in "have" list can change each time.
Please help!
This is an easy task for SQL:
proc sql;
create table want as select a.fruit as v1, b.fruit as v2
from have a, have b;
quit;
I'm guessing at the variable names to use, since you didn't supply any in your question.
I think I got the syntax right, but it might need a little tweak.
This is an easy task for SQL:
proc sql;
create table want as select a.fruit as v1, b.fruit as v2
from have a, have b;
quit;
I'm guessing at the variable names to use, since you didn't supply any in your question.
I think I got the syntax right, but it might need a little tweak.
You approach was also what came to mind for me. I can see DBA's having a huge issue with a Cartesian join, but for small tables that certainty works!
Register today and join us virtually on June 16!
sasglobalforum.com | #SASGF
View now: on-demand content for SAS users
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.