/* deabbr.sas Daniel Brockman 070805 cvt var1-var99 to var1 var2 var3 ... */ * tested 070805 ; %macro deabbr(List); /* * Usage example: %deabbr(var3-var8); * %let lhs=&greturn ; * * in this example, global var greturn contains * * var3 var4 var5 var6 var7 var8 * * Converts a hyphenated (or unhyphenated) list of variable names to * an unhyphenated list. * Returns the expanded list of variable names in global var greturn * Assigns values to global macro variables greturn* . * List should be list of variables syntactically correct for a datastep. * Incorrect lists can produce various kinds of errors, including some * hard to detect. deabbr doesn't attempt to check validity of the * List. * Executes a data step, creating a temporary dataset subsequently * deleted. * Invokes macros getdsname, mkvarlist2, delds. * deabbr is a function-style macro: %let lhs=%function([arg [, arg [...]]]) */ %global greturn; %getdsname(deabbr); %let temp1=&greturn ; /* name of tempo dataset */ data &temp1 (drop=i); /* create dataset containing the vars */ array a(*) &List ; do i=1 to dim(a); a(i)=i; end; ; /* mkvarlist2 needs >=1 obs */ run; %mkvarlist2(&temp1); /* list the vars in the dataset */ /* mkvarlist2 assigns var greturn */ %delds(&temp1); /* delete the tempo data set */ %mend deabbr;