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.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.