Checking/Count Cases with Main Dictionary

Discussions about CSEntry
Forum rules
New release: CSPro 8.0
Post Reply
Yass
Posts: 103
Joined: November 11th, 2017, 1:26 am

Checking/Count Cases with Main Dictionary

Post 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.
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: Checking/Count Cases with Main Dictionary

Post 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
Gregory Martin
Posts: 1777
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: Checking/Count Cases with Main Dictionary

Post by Gregory Martin »

You can also use the find function on the main dictionary if you want to check for an exact match.
Yass
Posts: 103
Joined: November 11th, 2017, 1:26 am

Re: Checking/Count Cases with Main Dictionary

Post by Yass »

Thanks Josh and Greg.
Post Reply