Here's another approach:
proc sql;
select id as closest_to_50
from ds1
having abs(id-50)=min(abs(id-50));
select id as closest_to_75
from ds1
having abs(id-75)=min(abs(id-75));
quit;
The difference between this and @Kurt_Bremser's approach is that PROC SQL selects all IDs with the minimum distance from 50 or 75, respectively, not only the first one in the list. So, if you added the value 53 and a second occurrence of 47 to your sample list, PROC SQL would select 47, 47 and 53 as CLOSEST_TO_50. If your desired result in this case was only 47 and 53 (i.e. no duplicates), you could "select distinct id ..." to achieve this.
... View more