Date: Wed, 20 Feb 2002 17:01:19 +0100
Reply-To: Jim Groeneveld <J.Groeneveld@ITGROUPS.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Jim Groeneveld <J.Groeneveld@ITGROUPS.COM>
Subject: Re: Help: fraction
Content-Type: text/plain
Hi Vicctw,
In your example you have .5 as the initial last factor for product B, while
you apply .6 as the overall factor in your desired result. Anyway, the
following program should do what you want:
DATA Basic;
LENGTH Product $1;
INPUT @3 Product @5 Year Amount Factor;
DATALINES;
A 1997 10 1
A 1998 11 1
A 1999 12 1
A 2000 13 0.3
B 1999 14 1
B 2000 15 1
B 2001 16 0.5
C 2000 17 1
C 2001 18 0.8
D 1999 19 1
D 2000 20 0.1
;
RUN;
PROC SORT DATA=Basic; BY Product DESCENDING Year; RUN;
DATA Result;
SET Basic; BY Product DESCENDING Year;
RETAIN Proport;
IF (FIRST.Product) THEN Proport = Factor;
IF (NOT LAST.Product) THEN
NwAmount = Amount * Proport + ( Amount - 1 ) * ( 1 - Proport );
ELSE NwAmount = Amount * Proport;
RUN;
PROC SORT DATA=Result; BY Product Year; RUN;
PROC PRINT DATA=Result; RUN;
Regards - Jim.
--
Y. (Jim) Groeneveld, MSc IMRO TRAMARKO tel. +31 412 407 070
senior statistician, P.O. Box 1 fax. +31 412 407 080
senior data manager 5350 AA BERGHEM IMRO TRAMARKO: a CRO
J.Groeneveld@ITGroups.com the Netherlands in clinical research
As time elapses it is getting later.
Notice of confidentiality: this e-mail may contain confidential information
intended for the addressed recipient only.
If you have received this e-mail in error please delete this e-mail and
please notify the sender so that proper delivery
can be arranged.
> -----Original Message-----
> From: vicctw [SMTP:vicctw@HOTMAIL.COM]
> Sent: Wednesday, February 20, 2002 4:09 PM
> To: SAS-L@LISTSERV.UGA.EDU
> Subject: Help: fraction
>
> Can someone help me? Here is my question.
> From:
> Product Year amount factor
> A 1997 10 1
> A 1998 11 1
> A 1999 12 1
> A 2000 13 0.3
>
> B 1999 14 1
> B 2000 15 1
> B 2001 16 0.5
>
> C 2000 17 1
> C 2001 18 0.8
>
> D 1999 19 1
> D 2000 20 0.1
> To:
> Product Year amount factor
> A 1997 10*0.3 1
> A 1998 11*0.3+10*0.7 1
> A 1999 12*0.3+11*0.7 1
> A 2000 13*0.3+12*0.7 0.3
>
> B 1999 14*0.6 1
> B 2000 15*0.6+14*0.4 1
> B 2001 16*0.6+15*0.4 0.6
>
> C 2000 17*0.8 1
> C 2001 18*0.8+17*0.2 0.8
>
> D 1999 19*0.1 1
> D 2000 20*0.1+19*0.9 0.1