DATA Step, Macro, Functions and more

Factorial variables in a do loop? Need a Help!LOL

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 9
Accepted Solution

Factorial variables in a do loop? Need a Help!LOL

Hi everyone, I've got three variables  "a","b","c", I would like to create a list of all possible combinations with these three variables which can be duplicate.The order doesn't matter. It's like factorial problem in high school. eg. 3!=27. The result should be like the following table.I'm really appreciate it if someone can help. Thanks.

 

seqPlayer1Player2Player3
01aaa
02aab
03aac
04aba
05abb
06abc
07aca
08acb
09acc
10baa
11bab
12bac
13bba
14bbb
15bbc
16bca
17bcb
18bcc
19caa
20cab
21cac
22cba
23cbb
24cbc
25cca
26ccb
27ccc

Accepted Solutions
Solution
‎11-28-2017 11:25 PM
Contributor
Posts: 37

Re: Factorial variables in a do loop? Need a Help!LOL

data temp;
  do player1='a','b','c';
    do player2='a','b','c';
	do player3='a','b','c';
	 output;
	 end;
	end;
  end;
run;

Hi.

 

Does this do what you are asking for?

View solution in original post


All Replies
Solution
‎11-28-2017 11:25 PM
Contributor
Posts: 37

Re: Factorial variables in a do loop? Need a Help!LOL

data temp;
  do player1='a','b','c';
    do player2='a','b','c';
	do player3='a','b','c';
	 output;
	 end;
	end;
  end;
run;

Hi.

 

Does this do what you are asking for?

Occasional Contributor
Posts: 9

Re: Factorial variables in a do loop? Need a Help!LOL

Posted in reply to ABritinAus

Problem solved in a light speed. Thanks!

Super User
Posts: 23,677

Re: Factorial variables in a do loop? Need a Help!LOL

CALL ALLCOMB

Super User
Posts: 23,677

Re: Factorial variables in a do loop? Need a Help!LOL

What's LOL about the question?
Occasional Contributor
Posts: 9

Re: Factorial variables in a do loop? Need a Help!LOL

It took me more than 10 minutes to figure it out. I was questioning about myself. Thank you for your reply.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 211 views
  • 2 likes
  • 3 in conversation