Dear SAS experts
I need your help with my data:
Here the detailed information:
My table is structured as follows:
I have 5 columns
1. Column serialNumber
2 Column: Name
3Rd column: First (time)
4Th column: Last (time)
5Th column: cycles (sec)
The 3rd and 4th columns contain always the same time, the duration column always contains 1 (sec)
Now I would like to summarize the time, if the difference in time is less than 10 seconds between two rows.
The column "name" may change, and the summary should take place only within the respective name (I hope this is understandable)
Example:
Can help me?
How can I handle it with SAS??
I would appreciate your help!
Try this (untested):
data tmp;
set have; by serialNumber name notsorted;
grp + (first.name or dif(last)<10);
run;
proc sql;
create table want as
select serialNumber, name, min(first) as first, max(last) as last, max(last)-min(first)+1 as cycle
from tmp
group by serialNumber, name, grp;
drop table tmp;
quit;
PG
Try this (untested):
data tmp;
set have; by serialNumber name notsorted;
grp + (first.name or dif(last)<10);
run;
proc sql;
create table want as
select serialNumber, name, min(first) as first, max(last) as last, max(last)-min(first)+1 as cycle
from tmp
group by serialNumber, name, grp;
drop table tmp;
quit;
PG
Dear PG Thanks a lot! I've just changed the "lower than" to a "greater than" sign, and it works fine! Best regards from Germany EH
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.
Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.
Find more tutorials on the SAS Users YouTube channel.