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.
Function to return the count of categories
Function to return the count of categories
- Attachments
-
- city.png (10.6 KiB) Viewed 6540 times
-
- Posts: 1851
- Joined: December 5th, 2011, 11:27 pm
- Location: Washington, DC
Re: Function to return the count of categories
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;
PROC PROGRAM_FF
errmsg("There were %d relationship codes", relationshipHashMap.length());
PROC RELATIONSHIP
relationshipHashMap(RELATIONSHIP) = true;
Re: Function to return the count of categories
Thanks, how can i do it in a tabulation application, adding a new data item as a categories counter?
-
- Posts: 1851
- Joined: December 5th, 2011, 11:27 pm
- Location: Washington, DC
Re: Function to return the count of categories
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
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