Page 1 of 1

Checking/Count Cases with Main Dictionary

Posted: September 24th, 2019, 4:43 am
by Yass
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.

Re: Checking/Count Cases with Main Dictionary

Posted: September 24th, 2019, 5:34 am
by josh
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

Re: Checking/Count Cases with Main Dictionary

Posted: September 24th, 2019, 7:14 am
by Gregory Martin
You can also use the find function on the main dictionary if you want to check for an exact match.

Re: Checking/Count Cases with Main Dictionary

Posted: September 24th, 2019, 7:55 am
by Yass
Thanks Josh and Greg.