Re: EpiData-list Digest, Vol 67, Issue 6
Dear Juergen (and all),
Thanks for your help. I want the MEMID to be automatically created after MEMBERNO has been entered. 4 variables will be entered, and the MEMID must be an agreggation of these 3 variables. So this is how the chk file command currently looks:
MEMBERNO RANGE 0 99 MUSTENTER AFTER ENTRY LET MEMID=String(LOCALITY)+String(VILLAGECOD)+String(HHOLDCODE)+String(MEMBERNO) END END
The MEMID must be 10 digits long, which means that the other variables must be a certain length, and therefore 'keep their zeros' at the beginning.
For example: LOCALITY = 1 (must be 1 digit) VILLAGECOD = 023 (must be 3 digits) HHOLDCODE = 0014 (must be 4 digits) MEMBERNO = 12 (must be 2 digits)
Juergen, I tried to include what you suggested within the brackets but in this case, the MEMID simply didn't appear. This is how it looked:
MEMBERNO RANGE 0 99 MUSTENTER AFTER ENTRY LET MEMID=String(LOCALITY*1000000000)+String(VILLAGECOD*1000000)+String(HHOLDCODE*1000)+String(MEMBERNO) END END
Any ideas why this didn't work? Your help is very much appreciated!
Thanks again,
Nicki
At 18:01 18/05/2009, you wrote:
Send EpiData-list mailing list submissions to epidata-list@lists.umanitoba.ca
To subscribe or unsubscribe via the World Wide Web, visit http://lists.umanitoba.ca/mailman/listinfo/epidata-list or, via email, send a message with subject or body 'help' to epidata-list-request@lists.umanitoba.ca
You can reach the person managing the list at epidata-list-owner@lists.umanitoba.ca
When replying, please edit your Subject line so it is more specific than "Re: Contents of EpiData-list digest..."
EpiData-list mailing list ___________________________________
Today's Topics:
- Consistency in number of digits (epidata-list@lists.umanitoba.ca)
- Re: Consistency in number of digits (epidata-list@lists.umanitoba.ca)
Message: 1 Date: Mon, 18 May 2009 14:28:12 +0100 From: epidata-list@lists.umanitoba.ca Subject: [EpiData-list] Consistency in number of digits To: epidata-list@lists.umanitoba.ca Message-ID: 6.2.5.6.0.20090518141625.03381728@ucl.ac.uk Content-Type: text/plain; charset="us-ascii"; format=flowed
Dear All,
I apologise if this question is simple but I really can't figure it out.
In creating my chk file, I need to ensure that four of the variables contain a certain number of digits. I know this is normally controlled by number fields the .qes file. However, in this instance I need zeros to be included at the beginning (eg. 0003) so that all responses contain the same number of digits. This is because I will be putting these 4 variables together to create a 10 digit identifier later in the chk file.
At the moment, whenever I enter 0003, the zeros are removed and I am left with just 3.
Does anyone know if there is a way to ensure the zeros remain, and to ensure that each variable entered contains 4 digits?
Many thanks in advance for your advice!
Nicki
Nicki Bailey Centre Administrator Leonard Cheshire Disability and Inclusive Development Centre Department of Epidemiology and Public Health University College London 4 Taviton Street, London, WC1H 0BT, UK Tel: +44 (0) 207 679 5589 Fax: +44 (0) 207 388 2291 www.lcdisability.org/idc
Message: 2 Date: Mon, 18 May 2009 16:05:12 +0200 From: epidata-list@lists.umanitoba.ca Subject: Re: [EpiData-list] Consistency in number of digits To: epidata-list@lists.umanitoba.ca Message-ID: 4A116B18.2010104@fifas.de Content-Type: text/plain; charset="iso-8859-1"
Dear Nicki,
how will your identifier look like? Why doesn`t it work like this?
v1=2 v2=105 v3=27 v4=7
ident= v1*1000000000 + v2*1000000 + v3*1000 + v4 = 2105027007 (with 3 digits/variable)
Regards Juergen
epidata-list@lists.umanitoba.ca schrieb:
Dear All,
I apologise if this question is simple but I really can't figure it out.
In creating my chk file, I need to ensure that four of the variables contain a certain number of digits. I know this is normally controlled by number fields the .qes file. However, in this instance I need zeros to be included at the beginning (eg. 0003) so that all responses contain the same number of digits. This is because I will be putting these 4 variables together to create a 10 digit identifier later in the chk file.
At the moment, whenever I enter 0003, the zeros are removed and I am left with just 3.
Does anyone know if there is a way to ensure the zeros remain, and to ensure that each variable entered contains 4 digits?
Many thanks in advance for your advice!
Nicki
Nicki Bailey Centre Administrator Leonard Cheshire Disability and Inclusive Development Centre Department of Epidemiology and Public Health University College London 4 Taviton Street, London, WC1H 0BT, UK Tel: +44 (0) 207 679 5589 Fax: +44 (0) 207 388 2291 www.lcdisability.org/idc _______________________________________________ EpiData-list mailing list EpiData-list@lists.umanitoba.ca http://lists.umanitoba.ca/mailman/listinfo/epidata-list
--
Freiburger Institut fuer angewandte Sozialwissenschaft e.V. FIFAS Erasmusstr. 16, D-79098 Freiburg Telefon: (0761) 28 83 64 Fax: (0761) 29 27 493 Web: www.fifas.de E-Mail: info@fifas.de
Dear Nicki,
if your variables are numbers, why do you use the "string"-function which converts the numbers to strings?
<< LET MEMID=String(LOCALITY*1000000000)+String(VILLAGECOD*1000000)+String(HHOLDCODE*1000)+String(MEMBERNO)
If you just multiply and add the 4 variables as numbers, the result will be a number with 10 digits (including zeros):
LET MEMID=(LOCALITY*1000000000)+(VILLAGECOD*1000000)+(HHOLDCODE*100)+(MEMBERNO)
Regards Juergen
epidata-list@lists.umanitoba.ca schrieb:
Dear Juergen (and all),
Thanks for your help. I want the MEMID to be automatically created after MEMBERNO has been entered. 4 variables will be entered, and the MEMID must be an agreggation of these 3 variables. So this is how the chk file command currently looks:
MEMBERNO RANGE 0 99 MUSTENTER AFTER ENTRY LET MEMID=String(LOCALITY)+String(VILLAGECOD)+String(HHOLDCODE)+String(MEMBERNO)
END END
The MEMID must be 10 digits long, which means that the other variables must be a certain length, and therefore 'keep their zeros' at the beginning.
For example: LOCALITY = 1 (must be 1 digit) VILLAGECOD = 023 (must be 3 digits) HHOLDCODE = 0014 (must be 4 digits) MEMBERNO = 12 (must be 2 digits)
Juergen, I tried to include what you suggested within the brackets but in this case, the MEMID simply didn't appear. This is how it looked:
MEMBERNO RANGE 0 99 MUSTENTER AFTER ENTRY LET MEMID=String(LOCALITY*1000000000)+String(VILLAGECOD*1000000)+String(HHOLDCODE*1000)+String(MEMBERNO)
END END
Any ideas why this didn't work? Your help is very much appreciated!
Thanks again,
Nicki
Just use the STRING function once. It should be
AFTER ENTRY MEMID=STRING(LOCALITY*1000000000 + VILLAGECOD*1000000 + HHOLDCODE*100 + MEMBERNO) END
For your example: LOCALITY = 1 (must be 1 digit) VILLAGECOD = 023 (must be 3 digits) HHOLDCODE = 0014 (must be 4 digits) MEMBERNO = 12 (must be 2 digits)
The addition inside the STRING(...) becomes
1000000000 1*1000000000 (add 9 zeros) 23000000 023*1000000 (add 6 zeros) 1400 0014*100 (add 2 zeros) 12 12 ---------- 1023001412 add up the numbers
I prefer to do the math this way: (((locality*1000+villagecod)*10000+hholdcode)*100+memberno
locality * 1000 because villagecod has 3 digits, then add villagecod then *10000 because hholdcode has 4 digits, then add hholdcode then *100 because memberno has 2 digits, then add memberno
If you have more than 1 digit in the leading code (say locality could be 01 to 99), then you have to account for the leading zero there as well. If locality had two digits and range 1 to 99, you need an 11-digit id and you do this:
memid = copy(string((((100+locality)*1000+villagecod)*10000+hholdcode)*100+memberno),2,11)
The math creates the string "101023001412" and the copy function gets rid of the leading 1, leaving "01023001412"
Jamie
Nicki wrote:
Juergen, I tried to include what you suggested within the brackets but in this case, the MEMID simply didn't appear. This is how it looked:
MEMBERNO RANGE 0 99 MUSTENTER AFTER ENTRY LET MEMID=String(LOCALITY*1000000000)+String(VILLAGECOD*1000000)+String(HHOLDCODE*1000)+String(MEMBERNO)
END END
Any ideas why this didn't work?
Messages to this list are sent out in one of two ways:
a. Each time a new message is created it is received one-by one b. A digest form, where only a mail is sent when a certain amount of information is on the list. Could be one two or several mails
When replying please make sure that you change the title/subject accordingly, such that it is clear what the contents is about.
If you receive the digest form make sure to copy the title from the individual mail and add a "re" in from . E.g.: re:
Compare these two titles from recent days: Re: [EpiData-list] Consistency in number of digits Re: [EpiData-list] Re: EpiData-list Digest, Vol 67, Issue 6
The first gives much better indication of content than the second one.
regards Jens Lauritsen EpiData Association
participants (1)
-
epidata-list@lists.umanitoba.ca