This macro accepts parameters that specify data set name prefixes and variable name prefixes and number of each thereof.
If you want a more abstract macro, say one that examines the members of a library and discovers the common names of the variables therein, you will need a more complex process.
Example:
%macro enwidening_rename(data=, n=, var=, m=);
%local i j letter;
%do i = 1 %to &n;
&data.&i ( rename = (
%do j = 1 %to &m;
%let letter = %sysfunc(byte(64+&j));
&var._&letter = &letter.&i
%end;
))
%end;
%mend;
data s1 s2 s3;
var_a = 010; var_b = 020; var_c = 030; output s1;
var_a = 110; var_b = 120; var_c = 130; output s2;
var_a = 210; var_b = 220; var_c = 230; output s3;
run;
options mprint;
data all;
merge
%enwidening_rename(data=s, n=3, var=var, m=3)
;
* no by statement ?, be careful and certain;
run;
Result
... View more