diff --git a/all.sas b/all.sas
index f8df375..54a070b 100644
--- a/all.sas
+++ b/all.sas
@@ -1598,6 +1598,35 @@ Usage:
&engine
%mend mf_getxengine;
+/**
+ @file
+ @brief Increments a macro variable
+ @details Useful outside of do-loops - will increment a macro variable every
+ time it is called.
+
+ Example:
+
+ %let cnt=1;
+ %put We have run %mf_increment(cnt) lines;
+ %put Now we have run %mf_increment(cnt) lines;
+ %put There are %mf_increment(cnt) lines in total;
+
+ @param [in] MACRO_NAME the name of the macro variable to increment
+ @param [in] ITER= The amount to add or subtract to the macro
+
+
Related Files
+ @li mf_increment.test.sas
+
+**/
+
+%macro mf_increment(macro_name,incr=1);
+
+ /* iterate the value */
+ %let ¯o_name=%eval(&&¯o_name+&incr);
+ /* return the value */
+ &&¯o_name
+
+%mend mf_increment;
/**
@file mf_isblank.sas
@brief Checks whether a macro variable is empty (blank)
diff --git a/base/mf_increment.sas b/base/mf_increment.sas
new file mode 100644
index 0000000..eeb7ce1
--- /dev/null
+++ b/base/mf_increment.sas
@@ -0,0 +1,29 @@
+/**
+ @file
+ @brief Increments a macro variable
+ @details Useful outside of do-loops - will increment a macro variable every
+ time it is called.
+
+ Example:
+
+ %let cnt=1;
+ %put We have run %mf_increment(cnt) lines;
+ %put Now we have run %mf_increment(cnt) lines;
+ %put There are %mf_increment(cnt) lines in total;
+
+ @param [in] MACRO_NAME the name of the macro variable to increment
+ @param [in] ITER= The amount to add or subtract to the macro
+
+ Related Files
+ @li mf_increment.test.sas
+
+**/
+
+%macro mf_increment(macro_name,incr=1);
+
+ /* iterate the value */
+ %let ¯o_name=%eval(&&¯o_name+&incr);
+ /* return the value */
+ &&¯o_name
+
+%mend mf_increment;
diff --git a/tests/base/mf_increment.test.sas b/tests/base/mf_increment.test.sas
new file mode 100644
index 0000000..ca3ad7e
--- /dev/null
+++ b/tests/base/mf_increment.test.sas
@@ -0,0 +1,35 @@
+/**
+ @file
+ @brief Testing mf_increment macro
+
+ SAS Macros
+ @li mf_increment.sas
+ @li mp_assert.sas
+
+**/
+
+%let var=0;
+
+%mp_assert(
+ iftrue=(
+ "%mf_increment(var)"="1"
+ ),
+ desc=Checking basic mf_increment usage 1,
+ outds=work.test_results
+)
+
+%mp_assert(
+ iftrue=(
+ "%mf_increment(var)"="2"
+ ),
+ desc=Checking basic mf_increment usage 2,
+ outds=work.test_results
+)
+
+%mp_assert(
+ iftrue=(
+ "%mf_increment(var,incr=2)"="4"
+ ),
+ desc=Checking incr option,
+ outds=work.test_results
+)