SAS Automatic naming in data step (merging) (partly unsolved)
Merging similar datasets in SAS makes it necessary to rename all variables in at least one of the datasets:
DATA NEWDATASET;
MERGE OLDDATASET1 OLDDATASET1 (RENAME=(VAR1=VAR1_2 VAR2=VAR2_2…..));
BY ID;
RUN;
Having many variables the renaming gets quite timeconsuming. I have been looking for a solution similar to the means procedure, where you can add a subscript to all variables. I asked around, finally also in the forum at sas.com. The answers came straight away, there is no smart solution.
So the best solution might be to create your own solution and let sas load it everytime it starts.
proc transpose data=data1 out=data2;
run;
data data2;
set data2;
newname=”prefix”!!_name_!!”suffix”;
run;
proc transpose data=data2 out=data1;
id newname;
run;