You can specify the delimiter in COUNTW. I do that a lot in examples like:
%let x=1,2,3,4;
%do i = 1 %to %sysfunc(countw(%superq(x),%str(,)));
%put %scan(%superq(x),&i,%str(,));
%end;
%superq above just masks things like commas, quotes etc. When using commas as the delimiter though in a macro %sysfunc make sure you wrap it with %str to tell SAS it's a macro text string and not separating options. If in a data step then you would do COUNTW(x,',') if you are using a comma as the delimiter.
... View more