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.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 16 replies
  • 2204 views
  • 4 likes
  • 5 in conversation