Solved
New Contributor
Posts: 4

# condensation of data

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!

Accepted Solutions
Solution
‎11-17-2012 12:20 PM
Posts: 5,394

## Re: condensation of data

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

PG

All Replies
Solution
‎11-17-2012 12:20 PM
Posts: 5,394

## Re: condensation of data

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

PG
New Contributor
Posts: 4

## Re: condensation of data

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

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
• 2 replies
• 377 views
• 0 likes
• 2 in conversation