Returns total number of words in a macro variable (NB only counts up to the first blank to allow blanks use
%wordcount_blank  this is used mainly to set footnotes)
%macro wordcount(list=,sep=%str( ));
%local count;
%let count=0; 
%do %while(%qscan(&list,&count+1,&sep) ne %str()) ;
%let count = %eval(&count+1); 
%end;
&count
%mend wordcount;
%do i=1 %to %wordcount(list=&groupvars. &byvars.);
create table
%scan(&groupvars. &byvars.,&i) as
select distinct
%scan(&groupvars. &byvars.,&i)
from
%scan(&datagroups. &byvar_dgs.,&i,%str( ))
where
%scan(&groupvars. &byvars.,&i) is not null
order by
%scan(&groupvars. &byvars.,&i);
%end;