Help using Base SAS procedures

Proc Expand Help

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 101
Accepted Solution

Proc Expand Help

[ Edited ]

Hello All,

 

I am working with Proc Expand and have a quick question.  I am pretty good wiht this procedure, but there is somemthing that I can't figure out.

 

I have data that takes the following form:

 

Obs      ID         Value:

1          1              3

2          1              4 

3          1              6

4          1              1

5          1              3

6          1              2

7          1              5

8          1              5

9          1              9

10          1              2

etc.

 

and I want to get a backwards looking moving average that DOES NOT take into account the current observation.  So, for example, if I wanted the the three obs backward moving average, I have been using TRANSFORMOUT = (movave 3) and then changing the obs value and remerging, but I want to be able to do that in one step in proc expand, so that I don't have to worry about data issues when remerging.

 

Ultimately, this is what i want:

 

The three day backward moving ave for obs 4 would be 13/3 and not 11/3.  I hope that makes sense.

 

Thanks!!

 

John

 


Accepted Solutions
Solution
‎09-25-2015 06:23 AM
Respected Advisor
Posts: 4,640

Re: Proc Expand Help

How about, simply:

 

convert value=y / transformout=(movave 3 lag 1);
PG

View solution in original post


All Replies
Solution
‎09-25-2015 06:23 AM
Respected Advisor
Posts: 4,640

Re: Proc Expand Help

How about, simply:

 

convert value=y / transformout=(movave 3 lag 1);
PG
Frequent Contributor
Posts: 101

Re: Proc Expand Help

Thank you very much!  Didn't know you could put those commands together like that!

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 330 views
  • 0 likes
  • 2 in conversation