%macro nvarlst(dset,vlist,nnvs); %*--Utility macro that returns a "double-dashed" list of all numberic variables in a specified sas dataset and a county of the number of variables in that list/dataset.; %*--mod 10/2002 to check sysver and set length of vlist variable to 32000 instead of 200 for version 7 or later; %*--first parm specifies existing sas dataset with numeric vars. Macro will create a list (with double dashes) of the numeric variables in that data set. 2nd parm specifies name of global parm to receive value of the generate sas variable list. 3rd parm specifies the name of the global parm to be assigned the count of numeric variables in the dataset. If values are not specified vlist will default to "varlist" and nvvs to "nvars"--; %if %quote(&dset)=%str() %then %let dset=_last_; %global _varlist _nvars; %if &vlist eq %str() %then %let vlist=_varlist; %if &nnvs eq %str() %then %let nnvs=_nvars; %local v8; %if %substr(&sysver,1,1) gt 6 %then %let v8=1; %else %let v8=0; %local vl vlm1; %if &v8 %then %let vl=32000; %else %let vl=200; %let vlm1=%eval(&vl - 1); proc contents noprint data=&dset out=_cc2_(keep=name type varnum where=(type=1)); proc sort; by varnum; run; data _null_; set _cc2_ end = last; length vlist $&vl; retain; retain _chain 1; pvarnum=lag(varnum); pname=lag(name); if _n_=1 then vlist=name; else if varnum ne (pvarnum+1) or last then do; if _chain gt 1 then vlist=trim(vlist)||'--'||pname; vlist=trim(vlist)||' '||name; _chain=1; end; else _chain+1; if last then do; call symput("&vlist",trim(vlist)); call symput("&nnvs",left(put(_n_,4.))); *** put vlist= _n_=; if length(vlist) ge &vlm1 then put ///'************************* WARNING: Length of numeric variable list' " returned by nvarlst macro is &vlm1 or more - Possible truncation ******************"; end; run; %mend nvarlst;