Date: Fri, 22 May 2009 11:01:51 -0400
Reply-To: Anna Cui <cuis@RPI.EDU>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Anna Cui <cuis@RPI.EDU>
Subject: data manipulation problem
Hi guys. I don't know SAS very well, but I think I have a quite
complicated data manipulation problem. I would really appreciate your help
on this.
The data looks like this:
obs date var
1 Aug-98 2
1 Feb-99 4
1 Jan-01 1
1 Mar-02 2
1 Mar-02 3
2 Jun-95 5
2 Nov-96 4
2 Sep-98 3
2 Sep-99 2
2 Oct-01 4
2 May-02 6
Each obs has multiple rows by month. Some months appear in multiple rows,
some months do not appear at all. For each obs each month, I need to
calculate the variance of "var" in the past three years, including the
months that do not appear. For example, for obs1 and Feb 1999, I need to
calculate the variance of "var" for its values between Feb.1996 and
Feb.1999, it is equal to variance of 2 and 4. For obs2, Feb 1999, it is
the variance of 3 and 4. If there is only 1 value or no value in the three
years, the variance would take 0.
I hope I explained it clearly. Thank you very much in advance.
Anna
|