[EpiData-list] Combining logical operators

epidata-list at lists.umanitoba.ca epidata-list at lists.umanitoba.ca
Thu Sep 8 00:52:03 CDT 2011


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.

 

I tried the following:

 

  BEFORE ENTRY

    IF ((teapd>0) AND (teapwk>0)) OR ((teapd>0) AND (teapmth>0)) OR
((teapwk>0) AND (teapmth>0))  THEN

      HELP "Only one of tea per day/week/month should have contain the
number of cups" TYPE=ERROR

    ENDIF

  END

 

This works for the paring of teapd and teapwk, but not the other
parings, i.e. the "if" condition seems to stop at the first OR. A way
around it is to split this into 3 statements (see below), but I suspect
there may be a more elegant way to do what I want. 

 

  BEFORE ENTRY

    IF (teapd>0) AND (teapwk>0) THEN

      HELP "Only one of tea per day/week/month should have contain the
number of cups" TYPE=ERROR

    ENDIF

  END

  BEFORE ENTRY

    IF (teapd>0) AND (teapmth>0) THEN

      HELP "Only one of tea per day/week/month should have contain the
number of cups" TYPE=ERROR

    ENDIF

  END

  BEFORE ENTRY

    IF (teapwk>0) AND (teapmth>0) THEN

      HELP "Only one of tea per day/week/month should have contain the
number of cups" TYPE=ERROR

    ENDIF

  END

 

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 at mcri.edu.au
www.mcri.edu.au <http://www.mcri.edu.au/> 


______________________________________________________________________
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