Removes the data that is associated with the specified key's current data item from the hash object.
Applies to: | Hash object |
specifies whether the method succeeded or failed.
specifies the name of the hash object.
specifies the key value whose type must match the corresponding key variable that is specified in a DEFINEKEY method call.
Restriction | If an associated hash iterator is pointing to the keyvalue, then the REMOVEDUP method does not remove the key or data from the hash object. An error message is issued. |
data testdup;
length key data 8;
input key data;
datalines;
1 10
2 11
1 15
3 20
2 16
2 9
3 100
5 5
1 5
4 6
5 99
;
data _null_;
length r 8;
dcl hash h(dataset:'testdup', multidata: 'y', ordered: 'y');
h.definekey('key');
h.definedata('key', 'data');
h.definedone();
call missing (key, data);
do key = 1 to 5;
rc = h.find();
if (rc = 0) then do;
h.has_next(result: r);
if (r ne 0) then do;
h.find_next();
h.removedup();
end;
end;
end;
dcl hiter i('h');
rc = i.first();
do while (rc = 0);
put key= data=;
rc = i.next();
end;
run;
key=1 data=10 key=1 data=5 key=2 data=11 key=2 data=9 key=3 data=20 key=4 data=6 key=5 data=5