Remove Duplicate valuesets

Discussions about CSEntry
Post Reply
Habtamu
Posts: 26
Joined: March 18th, 2024, 4:18 am

Remove Duplicate valuesets

Post by Habtamu »

Dear Cspro team
I need some assistance how remove duplicate value sets. I have external dictionary which is used to select household from it.The same household may be available in that external dictionary, but I used it for lookup to another applications for household selections, but appears more than one's times or doubled but I want only one.

I used the below functions, it works but the valuesets are Moren thanm Please help

Thank you

PROC TPMHHID
preproc
ValueSet Tempohh_vs;

forcase CROPSELECTED_DICT where SENUMID = TPENUMID do

//
Tempohh_vs.add(SHHNAME, SHH_ID);

enddo;

Tempohh_vs.sort();


setvalueset($, Tempohh_vs);
Attachments
Valuesets.jpg
Valuesets.jpg (122.47 KiB) Viewed 4708 times
Gregory Martin
Posts: 1840
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: Remove Duplicate valuesets

Post by Gregory Martin »

When you are building your value set, you can check if a code has already been added and then only add it if that has not happened:
if Tempohh_vs.codes.seek(SHH_ID) = 0 then
   
Tempohh_vs.add(SHHNAME, SHH_ID);
endif;
Habtamu
Posts: 26
Joined: March 18th, 2024, 4:18 am

Re: Remove Duplicate valuesets

Post by Habtamu »

Thank you, Gregory, for your help the code you sent is solved my issues on duplicate value sets.
Post Reply