Macros for SAS Application Developers
https://github.com/sasjs/core
mf_increment.sas
Go to the documentation of this file.
1 /**
2  @file
3  @brief Increments a macro variable
4  @details Useful outside of do-loops - will increment a macro variable every
5  time it is called.
6 
7  Example:
8 
9  %let cnt=1;
10  %put We have run %mf_increment(cnt) lines;
11  %put Now we have run %mf_increment(cnt) lines;
12  %put There are %mf_increment(cnt) lines in total;
13 
14  @param [in] macro_name The name of the macro variable to increment
15  @param [in] incr= (1) The amount to add or subtract to the macro
16 
17  <h4> Related Files </h4>
18  @li mf_increment.test.sas
19 
20 **/
21 
22 %macro mf_increment(macro_name,incr=1);
23 
24  /* iterate the value */
25  %let &macro_name=%eval(&&&macro_name+&incr);
26  /* return the value */
27  &&&macro_name
28 
29 %mend mf_increment;