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

A not uncommon problem with loop codes in macros can also be the scope of loop counter when one macro calls another.

Something like this could have accidentally incremented your loop counter one too many times.

%macro one ();
%do i= 1 %to 4;
%two
%put in macro one i is &i.;

%end;
%mend;
%macro two ();
%do i= 1 %to 5;
%put in macro two i is &i.;
%end;
%mend;
%one;

Note that the log shows a value of 6 for the macro variable &I even though neither loop explicitly uses it. So if you had an inner loop using the same range of 1 to 19 the last value could have been 20 creating the nonexistent set name.

jacksonan123
Lapis Lazuli | Level 10
Yes, that was part of my problem and hopefully I will be more aware next
time.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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
  • 3690 views
  • 4 likes
  • 5 in conversation