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
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;
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;
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
Both answers worked. Thank you so much!!
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.