Created
March 17, 2014 16:49
-
-
Save statgeek/9603186 to your computer and use it in GitHub Desktop.
SAS - Macro Loop Through Variable Lists
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*This Loops thoough a set of variables where the variables | |
are separated by "|". Any other delimiter can be used | |
and specified in the scan function as well*/ | |
%macro loop(varlist); | |
%let i=1; | |
%do %while (%scan(&varlist, &i, |) ^=%str()); | |
%let var=%scan(&varlist, &i, |); | |
%put &var; | |
*rest of SAS code goes here; | |
*Increment counter; | |
%let i=%eval(&i+1); | |
%end; | |
%mend; | |
%let temp=a|b|c|d|e; | |
%loop(&temp); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment