Date: Wed, 22 Apr 2009 20:12:14 -0400
Reply-To: Michael Bryce Herrington <mherrin@G.CLEMSON.EDU>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Michael Bryce Herrington <mherrin@G.CLEMSON.EDU>
Subject: Re: If, then statements
In-Reply-To: <OFC22ED9E7.D5D1B8C3-ON852575A0.0082ED6B-852575A1.000013CA@dom.com>
Content-Type: text/plain; charset=ISO-8859-1
Thanks, Ill give it a shot.
On Wed, Apr 22, 2009 at 8:00 PM, <Nathaniel.Wooding@dom.com> wrote:
> Michael
>
> Well, first off, I would say
>
> if purseindex ne 1 then return;
>
> This tells SAS to stop processing the particular obs, output it, and go to
> the next obs. This eliminates a large part of your code.
>
> Then I would write
>
> if clmgprice> 50 then Crank= 0 ;
> if 40000 <clmgprice<= 50000 then Crank= 1 ; else
> if 35000 <clmgprice<= 40000 then Crank= 2 ; else
> if 30000 <clmgprice<= 35000 then Crank= 3 ;
>
> if clmgprice1> 50 then C1rank= 0 ;
> if 40000 <clmgprice1<= 50000 then C1rank= 1 ; else
> if 35000 <clmgprice1<= 40000 then C1rank= 2 ; else
> if 30000 <clmgprice1<= 35000 then C1rank= 3 ;
>
> But beware, this is not tested.
>
> You might consider rewriting the first line in each group as
>
> if 50 < clmgprice <= 30000 then Crank= 0 ; else
> if 40000 <clmgprice1<= 50000 then C1rank= 1 ; else
> etc
>
> which is slightly better coding practice.
>
> Nat Wooding
> Environmental Specialist III
> Dominion, Environmental Biology
> 4111 Castlewood Rd
> Richmond, VA 23234
> Phone:804-271-5313, Fax: 804-271-2977
>
>
>
> Michael Bryce
> Herrington
> <mherrin@G.CLEMSO To
> N.EDU <http://n.edu/>>
> SAS-L@LISTSERV.UGA.EDU
> Sent by: "SAS(r) cc
> Discussion"
> <SAS-L@LISTSERV.U Subject
> GA.EDU <http://ga.edu/>> If, then statements
>
>
> 04/22/2009 07:44
> PM
>
>
> Please respond to
> Michael Bryce
> Herrington
> <mherrin@G.CLEMSO
> N.EDU <http://n.edu/>>
>
>
>
>
>
>
> I am looking for something more simple than I have. I want to write a data
> step that does the same thing the bellow code would do, but without having
> to write "if purseindex=1 and ..." before each statement.
>
> I was hoping something like:
> if purseindex=1 then
> if clmgprice>50 then Crank=1;
>
> Can you do this? Thanks!
> *
>
> data* apclmg;
>
> set apclmg;
>
> crank=-*1*;
>
> c1rank=-*1*;
>
> if purseindex=*1* and clmgprice>*50* then Crank=*0*;
>
> if purseindex=*1* and clmgprice1>*50* then C1rank=*0*;
>
> if purseindex=*1* and *40000*<clmgprice<=*50000* then Crank=*1*;
>
> if purseindex=*1* and *40000*<clmgprice1<=*50000* then C1rank=*1*;
>
> if purseindex=*1* and *35000*<clmgprice<=*40000* then Crank=*2*;
>
> if purseindex=*1* and *35000*<clmgprice1<=*40000* then C1rank=*2*;
>
> if purseindex=*1* and *30000*<clmgprice<=*35000* then Crank=*3*;
>
> if purseindex=*1* and *30000*<clmgprice1<=*35000* then C1rank=*3*;
>
>
>
> --
> Bryce Herrington
> Clemson University
> 111 Briar Lane
> Central, SC 29630
> mherrin@g.clemson.edu
> (863) 258-4758
>
>
> CONFIDENTIALITY NOTICE: This electronic message contains
> information which may be legally confidential and or privileged and
> does not in any case represent a firm ENERGY COMMODITY bid or offer
> relating thereto which binds the sender without an additional
> express written confirmation to that effect. The information is
> intended solely for the individual or entity named above and access
> by anyone else is unauthorized. If you are not the intended
> recipient, any disclosure, copying, distribution, or use of the
> contents of this information is prohibited and may be unlawful. If
> you have received this electronic transmission in error, please
> reply immediately to the sender that you have received the message
> in error, and delete it. Thank you.
>
--
Bryce Herrington
Clemson University
111 Briar Lane
Central, SC 29630
mherrin@g.clemson.edu
(863) 258-4758
|