| Date: | Tue, 11 Sep 2007 13:39:24 -0400 |
| Reply-To: | Doug Robinson <robinsond@BVU.EDU> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | Doug Robinson <robinsond@BVU.EDU> |
| Subject: | Problem with 'If...then; Else...' statements |
|---|
Hi all, I'm having trouble figuring out why I can't get SAS to do the
following statements. What I would SAS to do is evaluate one variable
(Cond_res) in relation to 4 other variables, and perform a calculation
depending on the conditional statement. The output these statements produce
indicate that SAS is only running the 'If...then' statements, but not the
'Else' statement. I'm wondering why the program isn't evaluating the
'If...then' statement, and moving onto the 'Else' statement when the initial
step isn't true.
Here's my programming:
if Year0 ge Cond_res then yr0diff = (Cond_res-Year0)*-1;
else yr0diff = Cond_res-Year0;
if Yearsub1 ge Cond_res then yr1diff = (Cond_res-Yearsub1)*-1;
else yr1diff = Cond_res-Yearsub1;
If Yearsub2 ge Cond_res then yr2diff = (Cond_res-Yearsub2)*-1;
else yr2diff = Cond_res-Yearsub2;
If Yearsub3 ge Cond_res then yr3diff = (Cond_res-Yearsub3)*-1;
else yr3diff = Cond_res-Yearsub3;
If Yearsub4 ge Cond_res then yr4diff = (Cond_res-Yearsub4)*-1;
else yr4diff = Cond_res-Yearsub4;
Thanks for your help,
Doug
|