I have a number of SAS datasets (around 30), each with the same structure but the sets are differentiated by a numerical suffix, e.g., DATA##, where # is some number. I have a number of other SAS dataset, e.g., INDICES##, each with one row (observation) of two columns of numerical variables named H and A. This pair of numbers represents the suffixes ## of two of the DATA## datasets that need to be merged for analysis. The number of second datasets is less than 20, and their suffixes are unrelated to those of DATA. I would like to be able to extract a pair of numbers from each of the second datasets in a way that I can use them to identify each of the pair of datasets from the first set that I need to merge, perhaps renaming them HDATAXX and ADATAZZ, where XX and ZZ are the relevant identifiers for the comparison. Several attempts at assigning the value of H or A to a name in a macro then appending that name to DATAxx have failed. One example follows, with 5 suffix-containing datasets: %macro trial; %do I = 1 %to 5; data temp; set INDICES&I; %let key=A; run; data DATA&key; set DATA&key; rename coreoff = coredef; run; %end; %mend trial; %trial; run; In this case, SAS interprets “DATA&key” as “DATAA”, which doesn’t exist. Any help appreciated. SAS Ver. 9.4 running in Windows 10.
... View more