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!!

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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