I'm using proc expand to calculate the 7 day midpoint average for a number of variables by date, and would like for it to stop calculating past the last raw value entered for each variable, where the last date of entry for variables are all different. This is my code: proc expand data=before out=after; convert variable1 = variable1 _avg variable2=variable2_avg/ method=none transformout=(CMOVAVE 7); run; This is the output: Date Variable1 Variable1_avg Variable2 Variable2_avg … … … … … 10-Jan-21 2.333333 5 5 11-Jan-21 2 2.333333 5.2 12-Jan-21 1 2.25 7 5.2 13-Jan-21 1.666667 5 5.2 14-Jan-21 2.25 6 5.25 15-Jan-21 2 2.333333 4.6 16-Jan-21 3 3 4.2 17-Jan-21 4 3 4 18-Jan-21 3 2 3.333333 19-Jan-21 4 5 3.333333 20-Jan-21 4 3.5 21-Jan-21 3.5 22-Jan-21 5 23-Jan-21 24-Jan-21 And I would like it to stop computing past the date of the last raw values, i.e. exclude the bolded values. Would I able to do this by modifying the proc expand statement? Or an array/another method for the large number of variables? EDIT: for clarification, there were no data entered for variable1 after January 17 and for variable2 after January 19. Thanks!
... View more