Checking/Count Cases with Main Dictionary

Discussions about CSEntry
Post Reply
Yass
Posts: 64
Joined: November 11th, 2017, 1:26 am

Checking/Count Cases with Main Dictionary

Post by Yass » September 24th, 2019, 4:43 am

Dear Cspro Team,

I have a situation I would like to first want check if a case exist in a file and at least a sub-string of it present in the file using the main dictionary, Not in an external dictionary , seems all the available functions such as forcase, locate, countcases works in an external dictionaries.

My example is my ID items are Cluster HH and MID, one can have multiple MID in a household, in this way I will like to first check if there is at least an existing case that has a substring of Cluster and HH after selecting HH, then I auto increase the MID for that particular household.

if cluster - 1 and HH - 1 if it does not exist then MD is 1 , if Cluster and HH exist then MID+1 (presume MID is sorted ascending). Kindly assist me in this regards

Thanks always.

josh
Posts: 1986
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: Checking/Count Cases with Main Dictionary

Post by josh » September 24th, 2019, 5:34 am

You are correct that forcase, loadcase etc... can only be used on external dictionary. However, you can use the function keylist() to get a list of all the cases in the main dictionary. It fills in a list of strings where each string is the case id (all the id-items concatenated together) of a case in the data file.

See the help page on keylist for details and an example: https://www.csprousers.org/help/CSPro/k ... ction.html

Gregory Martin
Posts: 1241
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: Checking/Count Cases with Main Dictionary

Post by Gregory Martin » September 24th, 2019, 7:14 am

You can also use the find function on the main dictionary if you want to check for an exact match.

Yass
Posts: 64
Joined: November 11th, 2017, 1:26 am

Re: Checking/Count Cases with Main Dictionary

Post by Yass » September 24th, 2019, 7:55 am

Thanks Josh and Greg.

Post Reply