i = valueset_name.removeDuplicates(ʃ by code ‖ label ʅ);
The
ValueSet.removeDuplicates function removes duplicate values from a
ValueSet object, leaving the first entry of a duplicate in the dynamic value set. Because a value set entry has both a code and a label, a duplicate is considered as follows, based on the argument to the function:
| Argument | Duplicate |
| — | A duplicate is when both the code and label match. |
| by code | A duplicate is when the code matches, even if the label differs. |
| by label | A duplicate is when the label matches, even if the code differs. |
When using a numeric value set with ranges (i.e., both from and to codes are defined), a duplicate code is considered one where both the from and to values are identical. For example, the following codes are considered unique: 0, 0 - 4, 0 - 9.
The function returns the number of duplicates removed from the value set. If the value set is read-only, the function returns
default.
PROC REPORT_DISTRICT
preproc
// for this dynamic value set, show only districts in the
// selected province where data has been collected
ValueSet districts_vs;
forcase PHC_DICT where PROVINCE = REPORT_PROVINCE do
districts_vs.add(DISTRICT_VS1, DISTRICT);
endfor;
// remove duplicates
districts_vs.removeDuplicates();
setvalueset(REPORT_DISTRICT, districts_vs);