Your last description sums it up. I don't know which column the named range will be referring to. I have now sorted out a work-around. A bit clunky, but I can rely on the range being just a single column, and so the imported datafile will only have one variable. Then I can use this code to pull out the name of the variable.
%macro FirstVName(data);
%* returns the name of the first variable in the file;
%let dsid = %sysfunc(open(&data,i));
%sysfunc(varname(&dsid,1))
%mend FirstVName;
... View more