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.