I have gotten the results I want with padding the data to fill in missing days, and then using arrays within a data step. I have also used PROC SQL merging a data set with itself multiple times.
Remember to vote up questions/answers you find interesting or helpful (requires 15 reputation points)
|
1
|
|
|
|
|
3
|
If you have SAS/ETS, it calculates a variety of moving averages: http://support.sas.com/onlinedoc/913/getDoc/en/etsug.hlp/expand_sect26.htm So if dataset IN has the variable X you can calculate the moving average:
|
||||||||
|
|
1
|
http://support.sas.com/kb/25/027.html data ds1; do patient='A','B','C'; do month=1 to 7; num=int(ranuni(0)*10); output; end; end; run; proc sort; by patient; run; %let n = 4; data ds2; set ds1; by patient; retain num_sum 0; if first.patient then do; count=0; num_sum=0; end; count+1; last&n=lag&n(num); if count gt &n then num_sum=sum(num_sum,num,-last&n); else num_sum=sum(num_sum,num); if count ge &n then mov_aver=num_sum/&n; else mov_aver=.; run; title 'Moving average within BY-Group'; proc print; run; |
||
|
|
|
0
|
I'm liking the PROC EXPAND. I have played around with some of the differnt options.
|
||
|
|