Date: Thu, 13 Sep 2007 21:50:27 -0700
Reply-To: David L Cassell <davidlcassell@MSN.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: David L Cassell <davidlcassell@MSN.COM>
Subject: Re: Problem with 'If...then; Else...' statements
Content-Type: text/plain; format=flowed
>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
>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
>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,
In addition to the comments you have already received, let me add something
You appear to have yearly data, stuck in a single row instead of preserved
vertically in a better database structure. This is already causing you to
have to grapple with writing the same sort of code over and over. But
the complications will just get worse as you continue to owrk with these
data. I think that you would do better to transform your data into a
tall-and-thin structure for better analysis (and database management).
I am also concerned, because you're grappling with time series data,
but you aren't using time series procs to do it. So perhaps you could
write back to SAS-L and explain just what your data are, and what you
are trying to do with them (in the long run).
David L. Cassell
3115 NW Norwood Pl.
Corvallis OR 97330
Can you find the hidden words? Take a break and play Seekadoo!