BookmarkSubscribeRSS Feed
statadm
Fluorite | Level 6
I'm trying to exclude negative time differences only when the time goes from somewhere in the 23:00 hour to the 00:00 hour. I can't seem to get this code right. Unfortunately, I do not have dates associated with the times or that would solve everything. Here is the code I'm working with:


DO I=1 TO 72;
IF DECONSET{I} NE . AND (DECONSET{I+1}-DECONSET{I}<=0) AND (DECONSET{I+1}-DECONSET{I} NE .) THEN PUT READER= CUSTOMID= DECONSET{I}= DECONSET{I+1}=;
END;

I don't want this code to output the times that go from 23:00 to 00:00. I tried writing in the code to exclude differences less than -83000 when '23:00't<=DECONSET{I}<='23:59't , but that didn't seem to work.

Thanks in advance for your help!


Message was edited by: statadm

Message was edited by: statadm Message was edited by: statadm
6 REPLIES 6
statadm
Fluorite | Level 6
skip Message was edited by: statadm
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Read this prior post with guidelines for special character conditions.

Scott Barry
SBBWorks, Inc.

http://support.sas.com/forums/thread.jspa?messageID=27609
statadm
Fluorite | Level 6
Thanks Scott, I figured it was something like that. It is working now.
statadm
Fluorite | Level 6
Does anyone have any idea how I can add something to my code to exclude times that go over the midnight hour?
Peter_C
Rhodochrosite | Level 12
> I'm trying to exclude negative time differences only
> when the time goes from somewhere in the 23:00 hour
> to the 00:00 hour. I can't seem to get this code
> right. Unfortunately, I do not have dates associated
> with the times or that would solve everything. Here
> is the code I'm working with:
>
>
> DO I=1 TO 72;
> IF DECONSET{I} NE . AND
> (DECONSET{I+1}-DECONSET{I} le 0) AND
> (DECONSET{I+1}-DECONSET{I} NE .) THEN PUT READER=
> CUSTOMID= DECONSET{I}= DECONSET{I+1}=;
> END;
>
> I don't want this code to output the times that go
> from 23:00 to 00:00. I tried writing in the code to
> exclude differences less than -83000 when
> '23:00't le DECONSET{I} le '23:59't , but that
> didn't seem to work.
>
> Thanks in advance for your help!
are we to assume your array DECONSET contains up to 72 times that represent consecutive events and you want to treat over midnight in a proper way so that if difference is negative and prior time is after 11pm then adapt the negative difference into a proper duration over midnight?
Instead of testing deconset(i) and using deconset(i+1) I would suggest testing deconset(i+1)
something like[pre]array interval(2:72) ;* to keep the calculations;
do i=2 to 72 ;
if missing(deconset(i-1)) then continue ;
if missing(deconset(i)) then continue ; * testing both allows occasional gaps;
inter = deconset(i) - deconset(i-1) ;
if inter LT 0 then do ;
if deconset(i) GE '23:0:0't then
inter = inter + '24:0:0't ;
if interval LT 0 then do ;
inter = . ;
put ( deconset(i-1) deconset(i) )(=) ' still negative interval' ;
end ;
interval(i) = inter ;
end ; [/pre] is that helpful?

That measures interval between consecutive pairs which are both non-missing..
An alternative model might measure between the latest and previous non-missing value.

peterC
statadm
Fluorite | Level 6
Thanks Peter, I will give this code a try.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 1092 views
  • 0 likes
  • 3 in conversation