SAS/IML Software and Matrix Computations

Statistical programming, matrix languages, and more
BookmarkSubscribeRSS Feed
tbanh
Fluorite | Level 6

Hi,

 

I was wondering if it was possible to have a do loop that satisfies two conditions. For example, in my SAS code:

 

do SampSize = 5 to 50 by 5;

 

I want my code to do the above do loop but satisfy the following condition as well:

 

do SampSize = 60 to 100 by 10;

 

Is there any way to combine the two conditions (e.g. do SampSize 5 to 50 by 5 and SampSize = 60 to 100 by 10)?

 

Thanks,

Tim

 

2 REPLIES 2
user24feb
Barite | Level 11

Try:

 

Data A;
  Do SampSize= 5 To 50 By 5, 60 To 100 By 10;
    Output;
  End;
Run;

IanWakeling
Barite | Level 11

If you are looking for an IML solution, then the data step syntax above will not work.  Other solutions would be to have two loops or save all the values of SamSize in a vector as follows:

 

  ss = do(5,50,5)||do(60,100,10);
  do i = 1 to ncol(ss);
    SampSize=ss[i];

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

From The DO Loop
Want more? Visit our blog for more articles like these.
Discussion stats
  • 2 replies
  • 2105 views
  • 1 like
  • 3 in conversation