Last active
January 6, 2018 05:04
-
-
Save statgeek/27e23c015eae7953eff2 to your computer and use it in GitHub Desktop.
SAS - moving min/max using arrays
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
How to calculate a moving min/max with a window of 4. | |
Resets by group ID | |
https://communities.sas.com/message/244232 | |
Courtesy of PGStats | |
*/ | |
data want; | |
array p{0:3} _temporary_; | |
set have; by object; | |
if first.object then call missing(of p{*}); | |
p{mod(_n_,4)} = price; | |
lowest = min(of p{*}); | |
highest = max(of p{*}); | |
run; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment