LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (September 2007, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
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
In-Reply-To:  <200709111739.l8BFiTx3019196@mailgw.cc.uga.edu>
Content-Type: text/plain; format=flowed

robinsond@BVU.EDU wrote: >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

In addition to the comments you have already received, let me add something else.

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).

HTH, David -- David L. Cassell mathematical statistician Design Pathways 3115 NW Norwood Pl. Corvallis OR 97330

_________________________________________________________________ Can you find the hidden words? Take a break and play Seekadoo! http://club.live.com/seekadoo.aspx?icid=seek_hotmailtextlink1


Back to: Top of message | Previous page | Main SAS-L page