%macro csqlist(__v__,nv,quotes=1,commas=1); %*--Originally coded 3-26-2000, John Blodgett--; %*--Last revised 8/2/2003 8:48AM--; %*--Accepts the name of a possibly multi-valued SELECT list parm. It will return a list of comma separated quoted values suitable for use as an argument with the "in" function. For example, if __v__=cnty and nv=3 and we have values cnty1=010 cnty2=340 and cnty3=189 then the value returned would be "010","340","189". Specify quotes=0 to specify no quotes (for numeric lists presumably) Specify commas=0 to have list be blank separated rather than comma separated. ---*; %local _i _ret; %let _ret=; %if &nv eq %then %let nv=0; %if &nv=0 %then %goto endmac; %do _i=1 %to &nv; %global &&__v__.&_i; %if "es %then "&&&__v__.&_i"; %else &&&__v__.&_i; %if &_i lt &nv %then %if &commas %then %str(,); %else %str( ); %end; %endmac: %mend csqlist;