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

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

1 ACCEPTED SOLUTION

Accepted Solutions
Linlin
Lapis Lazuli | Level 10

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;

View solution in original post

3 REPLIES 3
Linlin
Lapis Lazuli | Level 10

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;

PGStats
Opal | Level 21

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
vicky07
Quartz | Level 8

Both answers worked. Thank you so much!!

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1488 views
  • 5 likes
  • 3 in conversation