Duplicate Household Head Name

Discussions about editing and cleaning data
Post Reply
YFT_CBSD
Posts: 48
Joined: January 3rd, 2023, 12:36 am

Duplicate Household Head Name

Post by YFT_CBSD »

Hi,

What function can i use to display the duplicate household head name but different case id? This is a batch editing application.

For example.

140012
HHHead Name: Joe Coe

140013
HHHead Name: Joe Coe

Thanks. In advance
Gregory Martin
Posts: 1796
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: Duplicate Household Head Name

Post by Gregory Martin »

How about using the HashMap object: https://www.csprousers.org/help/CSPro/HashMap.html

Something like:
HashMap string hhNames(string);

if hhNames.contains(HH_NAME) then
    errmsg
("'%s' already encountered in case '%s'", HH_NAME, hhNames(HH_NAME));

else
   
// associate the household name with the case ID
   
hhNames(HH_NAME) = key(DICT_NAME);

endif;
YFT_CBSD
Posts: 48
Joined: January 3rd, 2023, 12:36 am

Re: Duplicate Household Head Name

Post by YFT_CBSD »

Thanks, the code is working.

Additionally i want to printout the age of John in case 140013, it should appear in 140012 errror message, how can i do this?

errmsg("'%s' already encountered in case '%s'", HH_NAME, hhNames(HH_NAME));

Case [140012] has 1 messages (0 E / 0 W / 1 U)
U -'Joe Coe' already encountered in case 140013
Gregory Martin
Posts: 1796
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: Duplicate Household Head Name

Post by Gregory Martin »

You can use the same idea of storing the name, but also have a variable with the ages.
HashMap numeric hhAges(string);

// ...

errmsg("'%s', aged %d, already encountered in case '%s'", HH_NAME, hhAges(HH_NAME), hhNames(HH_NAME));
Post Reply