Yes, macro language doesn't understand DATA step variables such as eof.
You seem to understand the right tools, why not use them:
proc sql;
select strip(var) into : vals separated by ',';
Or possible (but different):
select distinct strip(var) into : vals separated by ',';
If you really want this as a DATA step variable (although it is difficult to envision why), you could use:
data test;
longvar = "&vals";
run;
... View more