Did first solution work?
For the second one:
the first error --
ERROR: Indexed data set cannot be sorted in place unless the FORCE option is used.
means your dataset is indexed, if you wnat to sort the dataset you have to use force option. So sort for Oldtab was not sucsessful, and name changing from ItemId to ID did not happen.
You need to change to
proc sort data = OldTable out = OldTab(rename=(ItemId =id));
by Itemid;
run;
Since I don't index my dataset, I am not sure if you need force option or not. You can test it out yourself.
Second error:
ERROR: Variable id already exists on file NEWTable.
You already have a field called id in NewTable, Renaming another variable to ID make second sort unsucsessful.
You need to change to
proc sort data= NewTable (keep = OldId NewID) out = newTab(rename=(OldId = NewID));
by OldID;
run;
Third error:
Since first steps unsucsessful, Id is not in OldTable and the NewTable ID field is not the right one.
ERROR: Invalid DROP, KEEP, or RENAME option on file NEWTable.
ERROR: BY variable id is not on input data set OldTable.
WARNING: The variable id in the DROP, KEEP, or RENAME list has never been referenced.
WARNING: The data set WORK.MERGED may be incomplete. When this step was stopped there were 0
observations and 35 variables.
WARNING: Data set WORK.MERGED was not replaced because this step was stopped.
You need to chang to
Merge Oldtab(in = a) NewTab (in=b);
BTW,
Without seeing your dataset, I can only give you directions or logics, you need to learn how to debug your self.