%macro occurs(list,n); %*---first parm is a list of variable names (base), 2nd parm is the number of occurrences we want to generate based on that list. By "occurrence" we mean a version of that list with a numeric suffix appended to each name. So, for example, if list is "Name Age Sex" and n is 3 then the generate code is: Name1 Age1 Sex1 Name2 Age2 Sex2 Name2 Age3 Sex3. jgb, 4/07. ---; %local var i j nvars; %do i=1 %to 200; %let var=%scan(&list,&i); %if &var=%str() %then %goto aftloop; %let nvars=&i; %end; %aftloop: %do i=1 %to &n; %do j=1 %to &nvars; %scan(&list,&j)&i %end; %end; %mend occurs;