Have you looked at the SAS support
http://support.sas.com/ technical reference and conference papers, which provide much "free" information and programming techniques / methods.
A Google advanced search such as the one below yields several candidate results:
macro do loop processing site:sas.com
Also, if you are looking to "generate code" from source SAS variable and member names, consider also you may look at using DICTIONARY tables with PROC SQL (or their complimenting SAS views in SASHELP.Vxxxxxxx to work with generating SAS code based on known input data-values (variables, SAS library members, external file names).
Scott Barry
SBBWorks, Inc.
Suggested Google advanced search arguments, this topic / post:
macro language documentation site:sas.com
dictionary tables site:sas.com
macro generate sas code site:sas.com