Hi Jamie,
Thanks for your help. I hadn't considered the possibility of blanks hampering logic. It's helpful to know that a numeric missing value is a dot.
I won't change the QES file as it's been designed to reflect a paper survey where respondents can enter a response in each of per day/week/month. Any inconsistent responses will be dealt with at the data cleaning stage.
I've noticed you respond to a number of EpiData queries. Are you an EpiData developer or just an enthusiastic user?
Cheers,
Suzanna Vidmar Senior Research Officer Clinical Epidemiology and Biostatistics Unit
Murdoch Childrens Research Institute Royal Children's Hospital Flemington Road Parkville Victoria 3052 Australia
telephone: +61 3 9345 6372 facsimile: +61 3 9345 6000 email: suzanna.vidmar@mcri.edu.au www.mcri.edu.au -----Original Message----- From: epidata-list-bounces@lists.umanitoba.ca [mailto:epidata-list-bounces@lists.umanitoba.ca] On Behalf Of epidata-list@lists.umanitoba.ca Sent: Thursday, 8 September 2011 11:46 PM To: epidata-list@lists.umanitoba.ca Subject: Re: [EpiData-list] Combining logical operators
If teapd, teapwk or teapmth are left blank (i.e. missing), the logic may fail. The > and < comparisons cannot be guaranteed to work with missing values because EpiData does not like logic with missing values (e.g. "missing" AND false). If you turn on the option to flag all computational errors at Entry time, you will see the error.
Your logic is correct for the situation when a number is entered for ALL 3 fields.
I'm surprised that your second solution works - I've never seen more than one BEFORE ENTRY block in a field.
If unused entries are left blank, use the same logic but like this:
IF ((teapd<>.) and (teapwk<>.)) or ... THEN
Here is something you can do.
For TEAPD, TEAPWK and TEAPMTH, include:
AFTER ENTRY IF (teapd=.) then teapd = -1 ENDIF END
This ensures that the missing value -1 is entered.
In the BEFORE ENTRY block, you will also want to put something like:
IF ... THEN HELP "Only one of ..." GOTO teapd ENDIF
Otherwise, you can just ignore the help message and carry on.
I would probably have made the .qes look like this:
teafreq ## teaper ## (1=day, 7=week, 30=month)
This avoids the need for logic.
Jamie
On 2011-09-08, Suzanna wrote:
Is it possible to combine AND and OR into a single IF statement. If
so,
how? I have variables for the number of cups of tea consumed per day/week/month. The 3 variables are teapd, teapwk and teapmth. Only
one
of these should be filled in. -1 is the missing code and a value>0 indicates the number of cups consumed.
_______________________________________________ EpiData-list mailing list EpiData-list@lists.umanitoba.ca http://lists.umanitoba.ca/mailman/listinfo/epidata-list
______________________________________________________________________ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email
If you have any question, please contact MCRI IT Helpdesk for further assistance. ______________________________________________________________________
______________________________________________________________________ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email ______________________________________________________________________