Different Results for the DO IF than for the IF command

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

jgardner
Posts: 4
Joined: Sun Jul 29, 2012 6:41 pm

Different Results for the DO IF than for the IF command

Postby jgardner » Wed Jan 08, 2014 9:09 pm

This syntax creates a different result:

compute TxNumber = 0.
if (Match = 0) TxNumber = 1.
if (Match = 1) & (lag(NullEndDate) = 1) TxNumber = lag(TxNumber).
if ((Match = 1) & (CorrTxBeginDate <= lag(CorrTxEndDate) or datedif(CorrTxBeginDate,lag(CorrTxEndDate),"days") <= 1)) TxNumber = lag(TxNumber).
if ((Match = 1) & (CorrTxBeginDate > lag(CorrTxEndDate) & datedif(CorrTxBeginDate,lag(CorrTxEndDate),"days") > 1)) TxNumber = lag(TxNumber) + 1.
execute.
formats TxNumber (f2).

Than this syntax:

compute TxNumber = 0.
do if (Match = 0).
compute TxNumber = 1.
else if (Match = 1) and (lag(NullEndDate) = 1).
compute TxNumber = lag(TxNumber).
else if (Match = 1) and
(CorrTxBeginDate le lag(CorrTxEndDate) or datedif(CorrTxBeginDate,lag(CorrTxEndDate),"days") le 1).
compute TxNumber = lag(TxNumber).
else if (Match = 1) and
(CorrTxBeginDate gt lag(CorrTxEndDate) and datedif(CorrTxBeginDate,lag(CorrTxEndDate),"days") gt 1).
compute TxNumber = lag(TxNumber) + 1.
end if.
execute.
formats TxNumber (f2).

Can anyone explain why? I don't use the DO IF command very often, but perhaps I should more. Thank you for your help!

Who is online

Users browsing this forum: No registered users and 1 guest

cron