This is wonderful news that the SAS9 team is planning enhancements to the SCL functions!
If I can glom on (or happy to submit my own product suggestion), I wonder what the team would think about adding an option to make the VARNAME() function, honor drop/keep options?
I still think of it as a bug that ATTRN function can honor drop/keep, but VARNAME cannot. Test code:
%let dsid=%sysfunc(open(sashelp.class(keep=_numeric_))) ;
%put There are >>%sysfunc(attrn(&dsid,nvars))<< variables in sashelp.class(keep=_numeric_); %*works: returns 3, not 5;
%put The first variable is: %sysfunc(varname(&dsid,1)) ; %*should return Age but errors with argument out of range ;
%put The second variable is: %sysfunc(varname(&dsid,2)) ; %*should return Height errors with argument out of range ;
%put The third variable is: %sysfunc(varname(&dsid,3)) ; %*should return Weight (3rd numeric variable) but returns Age (3rd variable ignoring the KEEP option) ;
%let rc=%sysfunc(close(&dsid)) ;
I was told by colleagues on SAS-L many years ago in real SCL code, VARNAME() will honor keep/drop options in the way I expect, but somehow the data step language functions don't honor keep/drop. This requires some ugly workarounds when, for example, using these functions to build a list of variables from a dataset.
... View more