Here is how I would do it.
Save all the correct spellings of your fruits in a data set called fruits.
Read that data set into a hash object.
Read your have data set and look for the current value of fruit in the hash object. If it is there, do nothing (the spelling is correct). If it is not there, then run through the entire hash object and compare the current value of fruit to the correct spellings. If the distance between them is appropriately low, then replace the current value of fruit.
Let me know if this works for you 🙂
data have;
input id fruits $ price;
datalines;
1 grape 100
2 orange 120
3 grepe 110
4 apple 200
5 grapes 90
6 appll 190
;
data fruits;
input _fruits $;
datalines;
grapes
orange
apple
;
data want(drop=_:);
length _fruits $8;
if _N_=1 then do;
declare hash h(dataset:'fruits');
h.definekey('_fruits');
h.definedone();
declare hiter hi('h');
call missing(_fruits);
end;
set have;
if h.find(key:fruits) ne 0 then do;
do while (hi.next() = 0);
if compged(fruits, _fruits) le 200 then fruits=_fruits;
end;
end;
run;