Dear SAS Community,
| date | time | steps |
|---|---|---|
| 01JAN2015 | 0:00:00.000 | 3 |
| 01JAN2015 | 0:01:00.000 | 7 |
| 01JAN2015 | 0:02:00.000 | 9 |
| 01JAN2015 | 0:03:00.000 | 0 |
| 01JAN2015 | 0:04:00.000 | 11 |
| 01JAN2015 | 0:05:00.000 | 0 |
| 01JAN2015 | 0:06:00.000 | 0 |
| 01JAN2015 | 0:07:00.000 | 0 |
| 01JAN2015 | 0:08:00.000 | 0 |
| 01JAN2015 | 0:09:00.000 | 0 |
| 01JAN2015 | 0:10:00.000 | 0 |
| 01JAN2015 | 0:11:00.000 | 0 |
| 01JAN2015 | 0:12:00.000 | 0 |
| 01JAN2015 | 0:13:00.000 | 0 |
| 01JAN2015 | 0:14:00.000 | 0 |
| 01JAN2015 | 0:15:00.000 | 0 |
| 01JAN2015 | 0:16:00.000 | 23 |
| 01JAN2015 | 0:17:00.000 | 0 |
| 01JAN2015 | 0:18:00.000 | 21 |
| 01JAN2015 | 0:19:00.000 | 0 |
| 01JAN2015 | 0:20:00.000 | 0 |
| date | maximum_5 | interval |
|---|---|---|
| 01JAN2015 | 44 | 5 |
If your data is ALWAYS at 1 minute intervals something like this provides the total steps you are asking for. However it this may not be a general solution if your data crosses date boundaries.
This assumes your data looks exactly as posted. If you need this by date for a longer period of time there could well be other considerations.
data temp;
set have;
TotalSteps = sum(lag1(steps),lag2(steps),lag3(steps),lag4(steps),lag5(steps));
run;
proc summary data=temp nway;
class date;
var TotalSteps;
output out=want (drop= _type_ _freq_) max=maximum_5;
run;
If your data is not at minute intervals then this does not work. Also if you are looking at doing multiple intervals then it does not extend well.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.
Find more tutorials on the SAS Users YouTube channel.