Let's express this problem in a different way.
You have one dataset, let's call it TABLE1, with a variable called NAME. Whether or not it already has a variable named ID does not matter since it is empty.
You have a second dataset, let's call it TABLE2, which also have NAME but this one actually has values for the variable ID.
And you want a new dataset that has the information in TABLE1 with the addition of the values of ID from TABLE2. That sounds like a simple MERGE operation.
So first makes sure both TABLE1 and TABLE2 are sorted by NAME and then just MERGE them. If TABLE2 has other variables you don't care about you can use KEEP= dataset option to ignore them.
data want;
merge table1(in=in1) table2(keep=name id);
by name;
if in1;
run;
... View more