Your GROUP BY tells SAS at what levels to calculate. From your code snippet it looks like you've included Number in your GROUP BY when the numbers are different across the observations. SAS is correctly calculating what you've requested. Remove Numbers from the GROUP BY and Select statement. If you want to include it in the SELECT you'll need some sort of rule, ie max/min of which one to take. If it's first or last then then you'll need to go back to data step logic.
Here could give you a start :
option datestyle=mdy;
data have;
input id $ Number (Starttime Endtime) (: anydtdtm.);
format Starttime Endtime datetime.;
cards;
1a. 23 01/01/16:11:01:00 01/01/16:11:05:11
1a. 24 01/01/16:11:02:00 01/01/16:11:06:16
1a. 25 01/01/16:12:00:00 01/01/16:12:07:00
;
run;
data temp;
set have;
if lag(Endtime) lt Starttime or id ne lag(id) then g+1;
run;
data want;
set temp;
by g;
retain start num;
if first.g then do;start=Starttime;num=number;end;
if last.g then do;end=Endtime;output;end;
format start end datetime.;
drop Starttime Endtime number;
run;
You get what you want based this dataset .
CODE NOT TESTED
proc sort data=have ; by SITE END_TIME ;run;
data want;
set have;
by SITE ;
if first.SITE ;
run;
Sorry. I can't understand you. Show your data and code and the output you want .
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 the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.