I offer the following solution purely because my previous manager hated us using SQL - I think he just couldn't read it to be honest - so we had to come up with alternate solutions. %macro test(dsn,suffix); %global varlist; /*This section of code opens the data sets and determines the number of variables*/ %let dsid=%sysfunc(open(&dsn)); %let nvars=%sysfunc(attrn(&dsid,nvars)); %let varlist=; /*This section of code checks each variable name to see if the target suffix is found. If it is, then the variable name is added to VARLIST*/ %do i=1 %to &nvars; %let name=%sysfunc(varname(&dsid,&i)); %let chk=%sysfunc(reverse(&name)); %if %length(&name)>=%length(&suffix) %then %do; %if %sysfunc(reverse(%substr(&chk,1,%length(&suffix))))=&suffix %then %let varlist=&varlist &name; %end; %end; /*The following line of code closes the data set*/ %let rc=%sysfunc(close(&dsid)); %put &varlist; data &dsn.; set &dsn. (drop = &varlist); run; %mend; %test(a,_flag); Obviously this isn't as simple as using the SQL method, however it does produce a suitable outcome given the constraints imposed upon me. Regards, Scott
... View more