[EpiData-list] Combining logical operators

epidata-list at lists.umanitoba.ca epidata-list at lists.umanitoba.ca
Thu Sep 8 19:59:47 CDT 2011

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

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?


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 at mcri.edu.au
-----Original Message-----
From: epidata-list-bounces at lists.umanitoba.ca
[mailto:epidata-list-bounces at lists.umanitoba.ca] On Behalf Of
epidata-list at lists.umanitoba.ca
Sent: Thursday, 8 September 2011 11:46 PM
To: epidata-list at 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:

  IF (teapd=.) then
   teapd = -1

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

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.


On 2011-09-08, Suzanna wrote:

> Is it possible to combine AND and OR into a single IF statement. If
> 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
> 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 at lists.umanitoba.ca

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

This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 

More information about the EpiData-list mailing list