COUNT FUNCTION

Discussions about tabulating data in the designer or in batch mode
Forum rules
New release: CSPro 8.0
Post Reply
YFT_CBSD
Posts: 47
Joined: January 3rd, 2023, 12:36 am

COUNT FUNCTION

Post by YFT_CBSD »

what is the equivalent of FUNCTION in tablogic of tabulations?

my code in tablogic:
do numeric i = 1 while i <= totocc(PART_I)
IF count(PART_I where(SEX(i) = 1)) > 0 THEN
MALE= 1;
errmsg("MALE");
ENDIF;


in LST file: there are 3 "MALE"
but in the output table there are only 2 counts of MALE .

Tried running the tabulate freq, total male is 3.
MALE is added item in the Working Storage Dictionary.
How can i correct this?

Thanks
YFT_CBSD
Posts: 47
Joined: January 3rd, 2023, 12:36 am

Re: COUNT FUNCTION

Post by YFT_CBSD »

just observed that MALE item count per Record while the errmsg" MALE" count per Occurence
YFT_CBSD
Posts: 47
Joined: January 3rd, 2023, 12:36 am

Re: COUNT FUNCTION

Post by YFT_CBSD »

Any suggestions what function to use? Thanks
etuser
Posts: 85
Joined: September 3rd, 2019, 5:57 am

Re: COUNT FUNCTION

Post by etuser »

Do you want to count the number of male household members in a given household or just check the existence of a male household member in a household ? ERRMSG ("male") , lists the number of males found in an household i.e 3 males found with in two household .
YFT_CBSD
Posts: 47
Joined: January 3rd, 2023, 12:36 am

Re: COUNT FUNCTION

Post by YFT_CBSD »

Yes i want to count the total male per household in my tabulation application, but per checking if a househould has a male(example 2 or more male in a household) the tabulation count is per household not per individual. i just added the errmsg(); function to check if the used function is correct.

Any suggestions? i want to count the male per individual but i dont know what function to use in the field of Tablogic.
*Note this is a tabulation application.
Gregory Martin
Posts: 1777
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: COUNT FUNCTION

Post by Gregory Martin »

If you go to Table Attributes for your table (Ctrl+B), the second dropdown is for "Unit Tallied." Make sure the unit is the record with the individual on it, not a singly-occurring record (like a household record). The tally unit controls how often your table logic is executed, so changing it should give you the result you desire.
etuser
Posts: 85
Joined: September 3rd, 2019, 5:57 am

Re: COUNT FUNCTION

Post by etuser »

I think, you need to modify male =1; to male =male +1 and in your tabulation i.e. when you drag Male into the table, you need to use SUM instead of COUNT

my code in tablogic:
do numeric i = 1 while i <= totocc(PART_I)
IF count(PART_I where(SEX(i) = 1)) > 0 THEN
MALE= MALE + 1; {need to modify this }
errmsg("MALE");
ENDIF;
YFT_CBSD
Posts: 47
Joined: January 3rd, 2023, 12:36 am

Re: COUNT FUNCTION

Post by YFT_CBSD »

hi everyone. thanks.
Post Reply