Syntax coding

Moderators: statman, Analyst Techy, andris, Fierce, GerineL, Smash

leje
Posts: 1
Joined: Tue Aug 25, 2015 3:18 am

Syntax coding

Postby leje » Tue Aug 25, 2015 3:20 am

Hi guys,

I am trying to re-code some variables in my data-set, however the syntax I have written doesn't appear to work well.

The dichotomous variables of interest are:

Eye Drops Type 1 Left Eye (Yes, No, NA)
Eye Drops Type 1 Right Eye (Yes, No, NA)


Eye Drops Type 2 Left Eye (Yes, No, NA)
Eye Drops Type 2 Right Eye (Yes, No, NA)


Eye Drops Type 3 Left Eye (Yes, No, NA)
Eye Drops Type 3 Right Eye (Yes, No, NA)

Ultimately I am trying to code for the eye treated, i.e. left eye, right eye or both eyes (please note: patients can only receive one type of eye drop).


I have written code for all possible combinations but it appears incorrect in SPSS.

Could someone advise on how to fix this problem? I hope I have articulated this clearly. I would be grateful for any help.

COMPUTE EYE_TREATED=$sysmis.
if (Eye_Drops_Type_1_left_eye=1 and Eye_Drops_Type_1_right_eye=1) or (Eye_Drops_Type_2_left_eye=1 and Eye_Drops_Type_2_right_eye=1) or (Eye_Drops_Type_3_left_eye=1 and Eye_Drops_Type_3_right_eye=1) EYE_TREATED=3.
if (Eye_Drops_Type_1_left_eye=1 and Eye_Drops_Type_1_right_eye=2) or (Eye_Drops_Type_2_left_eye=1 and Eye_Drops_Type_2_right_eye=2) or (Eye_Drops_Type_3_left_eye=1 and Eye_Drops_Type_3_right_eye=2) EYE_TREATED=1.
if (Eye_Drops_Type_1_left_eye=1 and Eye_Drops_Type_1_right_eye=3) or (Eye_Drops_Type_2_left_eye=1 and Eye_Drops_Type_2_right_eye=3) or (Eye_Drops_Type_3_left_eye=1 and Eye_Drops_Type_3_right_eye=3) EYE_TREATED=1.
if (Eye_Drops_Type_1_left_eye=2 and Eye_Drops_Type_1_right_eye=1) or (Eye_Drops_Type_2_left_eye=2 and Eye_Drops_Type_2_right_eye=1) or (Eye_Drops_Type_3_left_eye=2 and Eye_Drops_Type_3_right_eye=1) EYE_TREATED=2.
if (Eye_Drops_Type_1_left_eye=2 and Eye_Drops_Type_1_right_eye=2) or (Eye_Drops_Type_2_left_eye=2 and Eye_Drops_Type_2_right_eye=2) or (Eye_Drops_Type_3_left_eye=2 and Eye_Drops_Type_3_right_eye=2) EYE_TREATED=0.
if (Eye_Drops_Type_1_left_eye=2 and Eye_Drops_Type_1_right_eye=3) or (Eye_Drops_Type_2_left_eye=2 and Eye_Drops_Type_2_right_eye=3) or (Eye_Drops_Type_3_left_eye=2 and Eye_Drops_Type_3_right_eye=3) EYE_TREATED=0.
if (Eye_Drops_Type_1_left_eye=3 and Eye_Drops_Type_1_right_eye=1) or (Eye_Drops_Type_2_left_eye=3 and Eye_Drops_Type_2_right_eye=1) or (Eye_Drops_Type_3_left_eye=3 and Eye_Drops_Type_3_right_eye=1) EYE_TREATED=2.
if (Eye_Drops_Type_1_left_eye=3 and Eye_Drops_Type_1_right_eye=2) or (Eye_Drops_Type_2_left_eye=3 and Eye_Drops_Type_2_right_eye=2) or (Eye_Drops_Type_3_left_eye=3 and Eye_Drops_Type_3_right_eye=2) EYE_TREATED=0.
if (Eye_Drops_Type_1_left_eye=3 and Eye_Drops_Type_1_right_eye=3) or (Eye_Drops_Type_2_left_eye=3 and Eye_Drops_Type_2_right_eye=3) or (Eye_Drops_Type_3_left_eye=3 and Eye_Drops_Type_3_right_eye=3) EYE_TREATED=0.
JonPedersen
Posts: 119
Joined: Wed May 25, 2011 7:07 am
Contact:

Re: Syntax coding

Postby JonPedersen » Wed Aug 26, 2015 12:34 pm

Hi,
I am getting slightly crosseyed by all the ors and ands, but the code will likely fail if NA is coded as missing.
Since you don't say what exactly goes wrong it is a bit difficult to answer more specific.
best
Jon

Who is online

Users browsing this forum: No registered users and 1 guest

cron