If I had the same problem as you originally stated I would use Tom's macro. Based on the way I program and my naming conventions I suggest that there may be other information available to you which you can use to provide a list of the variables in a data set for -- in your example a keep statement -- some processing. You can, for instance, use SQL to return a list of the variable in a data set into a macro variable: http://www.sascommunity.org/wiki/Making_Lists %let Libname = sashelp; %let Memname = class; PROC SQL; select Name into :Varlist separated by ' ' from Dictionary.Columns where Libname eq "%upcase(&Libname.)" and Memname eq "%upcase(&Memname.)" and MemType eq 'DATA'; quit; %Put Varlist: &VarList.; * then use the index function to check for a name in the list ; %let indexSex = %index(&VarList,Sex); %let existSex = %sysfunc(ifc(%index(&VarList,Sex) ,%nrstr(1) ,%nrstr(0) )); %Let Var = Gender; %let exist&Var = %sysfunc(ifc(%index(&VarList,&Var) ,%nrstr(1) ,%nrstr(0) )); %put _user_; NOTE: sashelp.class var names are in Propcase.==Initial Caps to ensure that this trick works be sure to standardize the case to either lowcase or upcase Personally I prefer lowcase. Ron Fehd macro maven
... View more