Rather than counting the number of unique vars first and using the resulting macro variable to set the upper limit for the INTO :, use the following syntax, saves a step:

proc sql;
select distinct var
into :varVal1 - :varVal&sysmaxlong
from dataset
;
%let varCount = &sqlobs;
quit;