Use of Do if statement

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Use of Do if statement

Deepa Bhat
Hi everyone,
 
I am creating some syntax to determine which injections are done safely. However I only want to select certain injections (variable M3_0=4 only). I'm thinking I would need to use the "Do if" statement. I want to write Do if M3_0=4 only.  I don't know how to incorporate it into my current syntax. I've bolded what I think is causing problems.  Any help would be appreciated!
 
This is the syntax I have so far which codes all injections regardless of whether M3_0=4.  Since this syntax needs to only apply to certain injections, the other injections should be coded as "not applicable." Any insight? Ihave 266 injections. This syntax should apply to only 52 of these injections. I am getting 47=0 (unable to be assessed) and 219= 2 (unsafe)
 
Compute safe_syr=9.
If (M3_0~=4) safe_syr= 9.
IF (M3_0=4) safe_syr=0.

IF (M3_6=1 and F3_15=1 and (F3_5=1) and (F3_17=1 or F3_17=2) and F3_18=1 and F3_19=1 and F3_20=2) safe_syr=1.
IF ((F3_5=2 or F3_5=3) or M3_6=2 or F3_15=2 or F3_15=3 or F3_17=3) safe_syr=2.
IF (F3_5= 4 or F3_5=5 or M3_6=3 or M3_17=3 or F3_17=4 or F3_18=2 or F3_18=3 or F3_19=3 or F3_20=3) safe_syr =0.
VALUE LABELS safe_syr  0 'unable to be assessed' 1 ' safe phlebotomy procedure' 2 'unsafe phlebotomy procedure' 9 'not applicable' .
Execute.
 
Thanks as usual,
Deepa
Reply | Threaded
Open this post in threaded view
|

Re: Use of Do if statement

Gyorgy Bea
Hi Deepa,

If your syntax should proceed only on cases when M3_0=4, you could try the following:


Do if M3_0=4.
   IF (M3_6=1 and F3_15=1 and (F3_5=1) and (F3_17=1 or F3_17=2) and F3_18=1 and F3_19=1 and F3_20=2) safe_syr=1.
   IF ((F3_5=2 or F3_5=3) or M3_6=2 or F3_15=2 or F3_15=3 or F3_17=3) safe_syr=2.
   IF (F3_5= 4 or F3_5=5 or M3_6=3 or M3_17=3 or F3_17=4 or F3_18=2 or F3_18=3 or F3_19=3 or F3_20=3) safe_syr =0.
Else.
   compute safe_syr=9.
End if.

VALUE LABELS safe_syr  0 'unable to be assessed' 1 ' safe phlebotomy procedure' 2 'unsafe phlebotomy procedure' 9 'not applicable' .
Execute.


Best regards,
Beata


From: Deepa Bhat <[hidden email]>
To: [hidden email]
Sent: Tuesday, March 24, 2009 6:22:28 PM
Subject: Use of Do if statement

Hi everyone,
 
I am creating some syntax to determine which injections are done safely. However I only want to select certain injections (variable M3_0=4 only). I'm thinking I would need to use the "Do if" statement. I want to write Do if M3_0=4 only.  I don't know how to incorporate it into my current syntax. I've bolded what I think is causing problems.  Any help would be appreciated!
 
This is the syntax I have so far which codes all injections regardless of whether M3_0=4.  Since this syntax needs to only apply to certain injections, the other injections should be coded as "not applicable." Any insight? Ihave 266 injections. This syntax should apply to only 52 of these injections. I am getting 47=0 (unable to be assessed) and 219= 2 (unsafe)
 
Compute safe_syr=9.
If (M3_0~=4) safe_syr= 9.
IF (M3_0=4) safe_syr=0.

IF (M3_6=1 and F3_15=1 and (F3_5=1) and (F3_17=1 or F3_17=2) and F3_18=1 and F3_19=1 and F3_20=2) safe_syr=1.
IF ((F3_5=2 or F3_5=3) or M3_6=2 or F3_15=2 or F3_15=3 or F3_17=3) safe_syr=2.
IF (F3_5= 4 or F3_5=5 or M3_6=3 or M3_17=3 or F3_17=4 or F3_18=2 or F3_18=3 or F3_19=3 or F3_20=3) safe_syr =0.
VALUE LABELS safe_syr  0 'unable to be assessed' 1 ' safe phlebotomy procedure' 2 'unsafe phlebotomy procedure' 9 'not applicable' .
Execute.
 
Thanks as usual,
Deepa