One possibility is to use a two-dimensional array, and use a macro to generate the variable names in the correct order, e.g.: %macro array_names(prefix,suffix1,suffix2); %local i j; %do i=1 %to %sysfunc(countw(&suffix1)); %do j=1 %to %sysfunc(countw(&suffix2)); &prefix.%scan(&suffix1,&i)%scan(&suffix2,&j)%end; %end; %mend; data _null_; retain v1a 1 v1b 2 v1c 3 x1 99 v2a 4 v2b 5 v2c 6 x2 999 v3a 7 v3b 8 v3c 9 x3 0; array v(3,3) %array_names(v,1 2 3,a b c); do i=1 to 3; do j=1 to 3; put v(i,j); end; end; run; I suggest using a macro because that is a good way of making sure you get the right variable names in the right order. So, instead of v[1]b you use v[1,2] etc.
... View more