|Date: ||Sat, 19 Mar 2005 12:05:39 -0500|
|Reply-To: ||Ya Huang <ya.huang@AMYLIN.COM>|
|Sender: ||"SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>|
|From: ||Ya Huang <ya.huang@AMYLIN.COM>|
|Subject: ||Re: problem about sum|
I think you need more explanation of your rule. The new rule seems to
conflict with the rule in the original post. Unless you have a clear
defined rule, I'm afraid that people here will not be able to help you.
On Sat, 19 Mar 2005 09:45:19 -0500, Wensui Liu <liuwensui@GMAIL.COM> wrote:
>Thank you all for your reply. Maybe I didn't explain clearly.
>What I want is:
>if weeks = 1, the sum = supply
>if weeks = 2, then sum = sum(supply, lag(supply))
>if weeks = 3, then sum = sum(supply, lag(supply), lag2(supply))
>Yes, there is no pattern at all, really depending on the value of
>weeks. Any idea?
>On Sat, 19 Mar 2005 08:44:09 -0500, Arthur Tabachneck
>> Hopefully, your example was flawed and the following is what you are
>> looking for:
>> data one;
>> input supply weeks;
>> 12 3
>> 22 1
>> 1 2
>> 3 1
>> 2 3
>> proc sort data=one;
>> by weeks;
>> proc means sum;
>> var supply;
>> by weeks;
>> Which will result in week1=25, week2=1 and week3=14.
>> On Sat, 19 Mar 2005 01:22:15 -0500, Wensui Liu <liuwensui@GMAIL.COM>
>> >Dear All,
>> >I have a problem on how to calculate the sum.
>> >supply weeks
>> > 12 3
>> > 22 1
>> > 1 2
>> > 3 1
>> > 2 3
>> >If weeks = 3, I want sum(12, 22, 1). If weeks = 1, then sum(22). If
>> >weeks = 2, then sum(1, 3) and so on....
>> >I have a big dataset with similar data like this and the weeks ranging
>> >from 1 to 8. I don't know how to calcuate this summation based on
>> >different values of weeks.
>> >Thank you so much for your help.
>WenSui Liu, MS MA
>Senior Decision Support Analyst
>Division of Health Policy and Clinical Effectiveness
>Cincinnati Children Hospital Medical Center