Hi
As I understand your question you're actually not looking for a count of unique observations but rather for a count of unique values per character variable.
If so then you have to scan the data set per variable. Luckily there are PROC's doing this for us - and they do it normally more efficient than we would code it.
Below approach uses Proc Freq to get a "record" per character variable and distinct value of this variable (missings included) and then uses ODS Output to collect the result and write it to a data set.
ods _all_ close;
ods output OneWayFreqs=work.Freqs(keep=table) ;
proc freq data=sashelp.class;
table _character_ /nocum nopercent missing;
run;
ods output close;
ods listing;
title "Unique Values per Character Variable";
proc sql;
select substr(Table,6) as Variable_Name format=$32. ,count(*) as N_UniqueValues format=8.
from work.Freqs
group by Table
;
quit;
title;
HTH
Patrick