Page 1 of 1
Function to return the count of categories
Posted: April 24th, 2024, 5:39 am
by YFT_CBSD
Hi, what function can i use to return the total count of categories?(highlighted in yellow mark)
for example data item of City. (please check the picture).
Tried using the STAT function but i only want to return the count of categories.
btw this is a batch editing tool
Thanks in advance.
Re: Function to return the count of categories
Posted: April 24th, 2024, 8:14 am
by Gregory Martin
One option is to use a HashMap to keep track of your values, and then count the number of keys in the HashMap, which will tell you how many unique values were added. For example:
HashMap relationshipHashMap;
PROC PROGRAM_FF
errmsg("There were %d relationship codes", relationshipHashMap.length());
PROC RELATIONSHIP
relationshipHashMap(RELATIONSHIP) = true;
Re: Function to return the count of categories
Posted: April 29th, 2024, 1:57 am
by YFT_CBSD
Thanks, how can i do it in a tabulation application, adding a new data item as a categories counter?
Re: Function to return the count of categories
Posted: May 1st, 2024, 3:27 pm
by Gregory Martin
You can use the working storage dictionary to create an item, e.g., Categories. Then, in post-calc logic, you can set the value of that cell to relationshipHashMap.length().
Here is some reading that may help you do this:
https://www.csprousers.org/help/CSPro/t ... logic.html
https://www.csprousers.org/help/CSPro/p ... cells.html