Hi all,
I'm trying to combine IF... THEN with LEGAL but somehow I'm having problems with it. Basically, what I want to do is to determine valid values for one variable based on the answer given to another variable. In the example below, the two vars are stateid and countyid: If stateid = 1 then countyid could be 01 or 04; if stateid = 2 then countyid could be 02, 03 or 05.
Example:
countyid IF stateid = 1 THEN LEGAL 01 04 END ENDIF IF stateid = 2 THEN LEGAL 02 03 05 END ENDIF MUSTENTER END
Hi Thomaz,
It seems you can't use the LEGAL command with IF. Below is another way, which actually may be more informative for data entry. CLEAR deletes the incorrect entry from countryid while "GOTO countryid" keeps the cursor in that field.
countryid IF (stateid=1) AND (countryid<>1) AND (countryid<>4) THEN HELP "Where stateid=1, the only legal values for countryid are 1 and 4." TYPE=ERROR CLEAR GOTO countryid ENDIF END
Regards,
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: Wednesday, 31 August 2011 7:09 AM To: epidata-list@lists.umanitoba.ca Subject: [EpiData-list] IF... THEN LEGAL
Hi all,
I'm trying to combine IF... THEN with LEGAL but somehow I'm having problems with it. Basically, what I want to do is to determine valid values for one variable based on the answer given to another variable. In the example below, the two vars are stateid and countyid: If stateid = 1 then countyid could be 01 or 04; if stateid = 2 then countyid could be 02, 03 or 05.
Example:
countyid IF stateid = 1 THEN LEGAL 01 04 END ENDIF IF stateid = 2 THEN LEGAL 02 03 05 END ENDIF MUSTENTER END
IF...THEN with different COMMENT LEGAL blocks does work, as shown in the help file for EpiData Entry, but it isn't perfect. This does not work with just LEGAL.
If you have simple sets of legal values, use a series of IF ... THEN blocks as suggested by Suzanna
Jamie
On 2011-08-30, at 5:08 PM, epidata-list@lists.umanitoba.ca wrote:
I'm trying to combine IF... THEN with LEGAL but somehow I'm having problems with it. Basically, what I want to do is to determine valid values for one variable based on the answer given to another variable. In the example below, the two vars are stateid and countyid: If stateid = 1 then countyid could be 01 or 04; if stateid = 2 then countyid could be 02, 03 or 05.
participants (1)
-
epidata-list@lists.umanitoba.ca