BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ballardw
Super User

At the end of an iterated do loop such as

do I= 1 to 8;

you find the value of I to be one more than the maximum value (unless you have some code to skip out of the loop early).

 

So in your code (slightly reformatted for legibility)

32 do i=1 to 8;
33    mindt = min(of dat[*]);
34    maxdt = max(of dat[*]);
35    if res{i}^='0' then _res{i}=i;
36 end;
37
38 if _res{i}=. then do;

line 38 uses the value of the index variable I after ending the loop and will have a value of 9. So the array index is out of range as you define the array _res to have 8 elements. Line 44 will have the same issue.

 

Note that you will get the exact same value for

33 mindt = min(of dat[*]); 
34 maxdt = max(of dat[*]); 

So these really do not need to be in any sort of loop.

 

 

skom1
Calcite | Level 5

Got it. Thank You very much

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 16 replies
  • 3033 views
  • 1 like
  • 7 in conversation