Macro Loops with Decimals

From sasCommunity
Jump to: navigation, search

The idea on this page was harvested from a Communities.on.SAS thread.

https://communities.sas.com/community/support-communities


Macro

*this will not work with decimals;
 
%macro ok(start=0,stop=3,step=1);
%do I = &start %to &stop %by &step;
    %put i =&i;
    %end;
%mend;
%ok()
 
*convert from iterative do to either until or while;
 
%macro do_decimals(start=0,stop=1,step=.1);
%let I = &start;
%do %until(%sysevalf(&I gt &stop));
    %put i =&i;
    %let I = %sysevalf(&I+&Step);
    %end;
%mend;
%do_decimals()

References

--Ronald_J._Fehd macro.maven == the radical programmer 09:37, 3 April 2013 (EDT)