## number combinations using sas

Solved
Frequent Contributor
Posts: 82

# number combinations using sas

Hi,

I am trying to get all possible 5 digit combinations of numbers starting from 0 to 4. I am not sure how to start or if it is doable. Has anybody done something like this before? Thanks in advance for your help!

Here is what i am looking for

00000

00001

00002

.

.

.

.

44442

44443

44444

Accepted Solutions
Solution
‎09-24-2012 08:09 PM
Super Contributor
Posts: 1,636

## Re: number combinations using sas

data have;

length all \$ 5;

do i=0 to 4;

do j=0 to 4;

do k=0 to 4;

do l=0 to 4;

do m=0 to 4;

all=cats(i,j,k,l,m);

output;

end;

end;

end;

end;

end;

keep all;

run;

proc print;run;

All Replies
Solution
‎09-24-2012 08:09 PM
Super Contributor
Posts: 1,636

## Re: number combinations using sas

data have;

length all \$ 5;

do i=0 to 4;

do j=0 to 4;

do k=0 to 4;

do l=0 to 4;

do m=0 to 4;

all=cats(i,j,k,l,m);

output;

end;

end;

end;

end;

end;

keep all;

run;

proc print;run;

Posts: 5,535

## Re: number combinations using sas

If you want numbers :

data test(keep=x);

format x z5.;

digits=5;

base=5;

do i = 0 to base**digits-1;

x = 0;

y = i;

do j = 1 to digits;

x = x + mod(y,base)*10**(j-1);

y = int(y/base);

end;

output;

end;

run;

PG

PG
Frequent Contributor
Posts: 82

## Re: number combinations using sas

Both answers worked. Thank you so much!!

🔒 This topic is solved and locked.