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
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.