|
Hi Jef,
there are two point, the second probably yielding a different
(correct?) result in your case.
1) with do-if-s the first true condition determines which
part of the syntax gets executed, ignoring all other parts.
with if-s all true conditions are executed in the
sequence they are written
2) with do-if-s, if a condition can't be evaluatet due to
missing values, spss skips pcorcessing until after end-if
So with do-if, if bdbj(#i) or bdpn(#i) are missing, processing
skips to after end-if, ignoring your 2nd and 3rd condition,
while the 2nd and 3rd if in your if-sequence gets evaluated.
HTH, Hauke
-----Ursprüngliche Nachricht-----
Von: Jed J. Teres [mailto:jjt2002@med.cornell.edu]
Gesendet: Mittwoch, 30. Juli 2003 16:09
An: SPSSX-L@VM.MARIST.EDU
Betreff: do if vs if
Can someone please explain the difference between "do if" and just regular
"if" for me?
I tried to use the following syntax, and if failed:
do if (bdpj(#i) lt 3 AND bdpn(#i) lt 2).
compute bdep(#i)=0.
else if (bdpj(#i) lt 3 AND missing(bdpn(#i)))
compute bdep(#i)=0.
else if (missing(bdpj(#i)) AND bdpn(#i) ge 2)
compute bdep(#i)=1.
end if.
But the following worked fine. I'm coming from a MATLAB background, and I
don't see a difference... what -is- the difference?
if (bdpj(#i) lt 3 AND bdpn(#i) lt 2)
bdep(#i)=0.
if (bdpj(#i) lt 3 AND missing(bdpn(#i)))
bdep(#i)=0.
if (missing(bdpj(#i)) AND bdpn(#i) ge 2)
bdep(#i)=1.
Thanks-
Jedediah Teres
Data Analyst
Weill Medical College of Cornell University
Department of Psychiatry
525 East 68th Street
New York, NY 10021
(212) 746-3874
|