BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Junyong
Pyrite | Level 9

I oftentimes monitor MACRO iterations as follows.

%macro repeat;
%do i=1 %to 100;
%if %sysfunc(mod(&i.,10))=0 %then %put NOTE: &i.th iteration now;
%end;
%mend;
%repeat;

I can do the same thing in DATA as follows.

data _null_;
do i=1 to 100;
if mod(i,10)=0 then put i;
end;
run;

I use this code as something similar to a loading bar—the code notifies at the 10th, 20th iterations, etc. I tried to do the identical thing in IML but failed because PUT in IML works differently.

proc iml;
do i=1 to 100;
if mod(i,10)=0 then put i;
end;
quit;

The log is here.

1    proc iml;
NOTE: IML Ready
2    do i=1 to 100;
3    if mod(i,10)=0 then put i;
4    end;
ERROR: No current file to write to.

 statement : PUT at line 3 column 21
5    quit;
NOTE: Exiting IML.
NOTE: The SAS System stopped processing this step because of
      errors.
NOTE: PROCEDURE IML used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds

Second, I tried CALL SYMPUT and %PUT instead, but still failed.

proc iml;
do i=1 to 100;
if mod(i,10)=0 then do;
call symputx("i",i);
%put &i.;
end;
end;
quit;

The corresponding log is here.

1    proc iml;
NOTE: IML Ready
2    do i=1 to 100;
3    if mod(i,10)=0 then do;
4    call symputx("i",i);
5    %put &i.;
100
6    end;
7    end;
8    quit;
NOTE: Exiting IML.
NOTE: PROCEDURE IML used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds

Is there any considerable alternative in IML? Much appreciate again.

1 ACCEPTED SOLUTION
3 REPLIES 3
Junyong
Pyrite | Level 9

Thanks for the helpful post, but I have one additional question about that. I just tried the following.

proc iml;
i=1;
submit i;
%put NOTE: &i;
endsubmit;
quit;

Sadly, the %PUT inside spits out nothing due to the colon : right after the NOTE. I want to use the NOTE: if possible as it highlights anything in a log. Do you have any suggestion in this respect?

Rick_SAS
SAS Super FREQ

By default, NOTEs are turned  off in a SUBMIT block. Use OPTIONS NOTES at the top of the SUBMIT block, as follows:

 

/* write NOTE: <message> */
submit i;
   options notes; /* turn on notes */  
   %put NOTE: Iteration = &i; /* displays NOTE: in color */
endsubmit;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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