Date: Thu, 23 Apr 2009 05:07:52 -0400
Reply-To: Søren Lassen <s.lassen@POST.TELE.DK>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Søren Lassen <s.lassen@POST.TELE.DK>
Subject: Re: If, then statements
Content-Type: text/plain; charset=ISO-8859-1
As you are doing the same logic for two sets of variables,
using a format is probably simpler after all:
proc format;
value crank
50 <- 30000 = '0'
30000<- 35000 = '3'
35000<- 40000 = '2'
40000<- 50000 = '1'
other='-1'
;
run;
data apcmlg;
set apcmlg;
if purseindex=1 then do;
crank=input(put(clmgprice,crank.),2.);
c1rank=input(put(clmgprice1,crank.),2.);
end;
else do;
crank=-1;
c1rank=-1;
end;
run;
Regards,
Søren
On Wed, 22 Apr 2009 19:44:59 -0400, Michael Bryce Herrington
<mherrin@G.CLEMSON.EDU> wrote:
>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
|