%macro dolist(list,pre,post,dlm=,start=1,end=n); /*--Utility macro that generates an edited variable list. The list parm specified a normal (no dashes or double dashes) SAS variable list. pre and post indicate string to be pre- or post-appended to each item in &list in order to form the output list. The result of the macro is the edited list. Example: %dolist(name age zip,pre=edit,post=2) would result in the list: editname2 editage2 editzip2 . If dlm is specified then it will be used as a delmiter between the items in the generated list. --- */ %local nl i entry; %let nl=%lenlst(&list); %if %quote(&end) ne %str(n) %then %let nl=&end; %do i=&start %to &nl; %let entry=%scan(&list,&i); &pre&entry&post &dlm %end; %mend dolist;