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

Solved
Occasional Contributor
Posts: 9

# 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.

 seq Player1 Player2 Player3 01 a a a 02 a a b 03 a a c 04 a b a 05 a b b 06 a b c 07 a c a 08 a c b 09 a c c 10 b a a 11 b a b 12 b a c 13 b b a 14 b b b 15 b b c 16 b c a 17 b c b 18 b c c 19 c a a 20 c a b 21 c a c 22 c b a 23 c b b 24 c b c 25 c c a 26 c c b 27 c c c

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?

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

Problem solved in a light speed. Thanks!

Super User
Posts: 23,677

CALL ALLCOMB

Super User
Posts: 23,677

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

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.