Glad you found a solution. It seems that the LOC function uses char values and if the length does not match it will not be found.
Another way of doing this, would be to get the values into an array and then use this expression:
newArray = columnNamesArray & lookupArray;
This will return only common values in both arrays, see CASL Array Operrators for more details. the length of the values does not seem to matter. Here is the code I used for testing:
%let namer=ts;
%let namer2=a123456789b123456789c123456789;
%let namer3=a123456789b123456789c123456789d1;
%let casy=cars;
%let liby=casuser;
cas mySession sessopts=(caslib="&liby");
libname casuser cas caslib="casuser";
data casuser.cars;
set sashelp.cars;
format &namer &namer2 datetime20. ;
&namer=intnx('dtminutes', datetime(), rand('integer', -1000, 0));
&namer2=&namer;
&namer3=put(rand('uniform', 0, 1), best12.);
run;
proc cas;
table.columninfo result=r / table="&casy";
columns = '';
search_cols='';
/* array with names to search for */
search_cols_array = {};
do i = 1 to r.columninfo.nrows;
if index(UPCASE(r['columninfo'][i,7]), 'DATETIME') THEN do;
symput('col', ifc(prxmatch('m/\s/i',r[1,i].column), '''||r[1,i].column||''n', r[1,i].column));
/* fill array with search values */
search_cols_array = search_cols_array + r[1,i].column;
columns = columns||' '||symget('col');
search_cols = strip(search_cols||'|'||symget('col'));
end;
end;
print(note) "search_cols_array=" search_cols_array;
symput('ok_list', substrn(search_cols,2,length(search_cols)-1));
symput('varlist', substrn(columns,2,length(columns)-1));
run;
%put &=ok_list;
%put &=varlist;
run;
simple.summary result=sumres / subset={'min', 'max'}, table="&casy";
/* describe sumres.summary; */
sumlist=findtable(sumres);
colNames = GETCOLUMN(sumlist, "Column");
print(note) "colNames=" colNames;
commonArray = colNames & search_cols_array;
print(note) "commonArray summary=" commonArray;
run;
simple.distinct result=dist / table="&casy";
describe dist.distinct;
colNames = GETCOLUMN(dist.distinct, 1);
print(note) "colNames=" colNames;
commonArray = colNames & search_cols_array;
print(note) "commonArray distinct=" commonArray;
run;
quit;
... View more