Auto serial number generation

Discussions about CSEntry
Forum rules
New release: CSPro 8.0
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: Auto serial number generation

Post by josh »

With the current logic after changing the serial you have to pass through the other rows of the roster to update their serial numbers based on the earlier ones. For example if you change the serial number in the first row then keep hitting enter to move the through the roster and the serial in later rows will update when you get to them. You can do it more quickly by just clicking in a field at the end of the roster to jump through them directly.

If you want to have the other serial numbers in the roster automatically as soon you update the first serial the logic gets a bit a more tricky and would probably not be worth doing. You would need to implement a loop using "do while" from the current row (curocc) through the last entered row and update the numbers being careful not include the ones that were skipped.
KAPALA
Posts: 13
Joined: July 18th, 2017, 1:09 am

Re: Auto serial number generation

Post by KAPALA »

Josh i have the same concern, in a roster,i want to check the eligibility criteria that i only want to interview women 15-45 who lived in a household for 3 months. So i have a question for Sex (1 = Male,2 = Female), Age (--),Living in 3 months ago (1=Yes, 2= No) now the next questions is Eligible (1=Yes, 2=No)
Now want to see the serial number of eligible women in this field, can you help me how i can construct my programming language?

Thank you
Gregory Martin
Posts: 1777
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: Auto serial number generation

Post by Gregory Martin »

You can loop through your roster to identify eligible women, or you can also use the seek function. This code, for example, will identify the eligible women:
numeric indexEligible = seek(SEX = 2 and AGE in 12:49 and LIVE_IN_HH = 1);

while indexEligible > 0 do
    errmsg("Person #%d is eligible",indexEligible);
    indexEligible = seek(SEX = 2 and AGE in 12:49 and LIVE_IN_HH = 1,indexEligible + 1);
enddo;
Wafick
Posts: 1
Joined: August 15th, 2018, 6:30 am

Re: Auto serial number generation

Post by Wafick »

josh wrote:In that case you don't need to worry about loadsetting/savesetting. That is only needed when you need to seralize across different cases. In a roster you can smartpoints daily allowance calculator just use the max function to get the current largest value and add one to that. Something like this:
PROC PER_SERIAL
preproc

// Skip if no women 15 to 49
ask if WOMEN_15_49  = 1;

if max(SERIAL) = default then
    
// when max returns default there are no previous values in roster so this must be first
    SERIAL = 1;
else
    
// add one to largest value so far
    SERIAL = max(SERIAL) + 1;
endif;
its working.
Post Reply