Created
July 11, 2017 20:28
-
-
Save statgeek/07a3708dee1225ceb9d4aa75daab2c52 to your computer and use it in GitHub Desktop.
SAS Time Series Data - Fill time series with missing time points and calculate moving average
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
/*this is an example of time series data. | |
1. Create a time series data set with missing intervals (IBM) | |
2. Add back missing entries using PROC TIMESERIES (IBM_NO_MISSING) | |
3. Calculate moving average - 12 month average | |
*/ | |
/*1*/ | |
data ibm; | |
set sashelp.stocks; | |
where stock='IBM'; | |
if month(date)=7 then | |
delete; | |
run; | |
proc sort data=ibm; | |
by date; | |
run; | |
/*2*/ | |
proc timeseries data=ibm out=ibm_no_missing; | |
id date interval=month start='01Aug1986'd end='01Dec2005'd; | |
var open; | |
run; | |
/*3*/ | |
proc expand data=ibm_no_missing out=want; | |
id date; | |
convert open = open_12 / method=none transformout= (movave 12); | |
run; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment