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

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!

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

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.

 

 

View solution in original post

2 REPLIES 2
Astounding
PROC Star

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.

 

 

noling
SAS Employee

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

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

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

View all other training opportunities.

Discussion stats
  • 2 replies
  • 380 views
  • 1 like
  • 3 in conversation