Page 1 of 1

COUNT FUNCTION

Posted: May 31st, 2023, 5:56 am
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

Re: COUNT FUNCTION

Posted: May 31st, 2023, 6:35 am
by YFT_CBSD
just observed that MALE item count per Record while the errmsg" MALE" count per Occurence

Re: COUNT FUNCTION

Posted: June 4th, 2023, 7:30 pm
by YFT_CBSD
Any suggestions what function to use? Thanks

Re: COUNT FUNCTION

Posted: June 5th, 2023, 4:16 am
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 .

Re: COUNT FUNCTION

Posted: June 5th, 2023, 7:05 am
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.

Re: COUNT FUNCTION

Posted: June 5th, 2023, 8:06 am
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.

Re: COUNT FUNCTION

Posted: June 5th, 2023, 8:11 am
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;

Re: COUNT FUNCTION

Posted: June 5th, 2023, 11:01 pm
by YFT_CBSD
hi everyone. thanks.