View previous topic :: View next topic
|
Author |
Message |
vasanthz
Global Moderator
Joined: 28 Aug 2007 Posts: 1742 Location: Tirupur, India
|
|
|
|
Hi,
There is an input file which has the below details.
Code: |
Jobname, start-date & time, end-date & time, start-timepart, end-timepart, elapsed-time |
I am trying to find the list of jobs that were active during the time frame from 09:00 to 16:00.
Could you please help me with the algorithm of how to solve this.
I tried something like...
Code: |
If elapsed-time > 17 hours then write the record to output; /* 24 hours minus the 7 hour window */
else if (end-timepart > start-timepart) then /* we are checking jobs that did not run through midnight */
do ( if end-timepart > 09:00 and start-timepart < 16:00 then write the record to output; ) |
I am unable to handle the logic for jobs that run through midnight into the following day. Could you please help.
Thanks & Regards, |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Code: |
( Start within period )
OR ( End within period )
OR ( Start before period
AND ( ( End after period )
OR
( End not reached yet ) ) |
|
|
Back to top |
|
|
steve-myers
Active Member
Joined: 30 Nov 2013 Posts: 917 Location: The Universe
|
|
|
|
Presumably your real input data is SMF.
SMF is difficult because if the job started before your start time and ended after your start time there may not be anything in SMF. Another issue with SMF is the data contains dates and times as paired, but otherwise separate fields.
In any event, if I were dealing with real SMF data and had your task I'd try to write something like this, in high level analysis rather than real code.
If job start date/time < date/time interval start & job end date/time >= date/time interval end then job was active for the entire interval.
If job start date/time < date/time interval start & job end date/time < date/time interval end the job was active for the time from interval start to job end date/time.
If job start date/time >= date/time interval start & job end date/time <= date/time interval end then job was active in the interval from job start to job end.
If job start date/time >= date/time interval start & job end date/time > date/time interval end then job was active from job start to interval end.
It might make your analysis easier if you think in those cases rather than write some compound, complex IF statement no one will be able to figure out without hours of skull sweat. |
|
Back to top |
|
|
vasanthz
Global Moderator
Joined: 28 Aug 2007 Posts: 1742 Location: Tirupur, India
|
|
|
|
Hi Bill and Steve,
Thanks for the suggestions. I went with Bill's algorithm & implemented the begin or end within duration condition and the job seems to work OK for now.
Also included a condition to discard records that have no start or end time.
Quote: |
It might make your analysis easier if you think in those cases rather than write some compound, complex IF statement no one will be able to figure out without hours of skull sweat |
This program is only for the analysis study, that I am tasked to perform. I doubt anyone would use this code besides me.
Also there are thousands of records to sift through and a program is the only way.
The below lines of code in SAS seems to work.
Code: |
IF MISSING(READTIME_TM) THEN DELETE;
IF MISSING(TERMTIME_TM) THEN DELETE;
/* WE ARE FINDING JOBS THAT WERE ACTIVE FROM 09:00 TO 16:00 */
IF EXECTM > = '17:00:00'T THEN OUTPUT; /* 24 HOURS - THE INTERVAL */
ELSE IF TERMTIME_TM > READTIME_TM THEN DO;
IF TERMTIME_TM > '09:00:00'T AND
READTIME_TM < '16:00:00'T THEN OUTPUT;
END;
ELSE DO; /* CHECK IF THE JOB HAS BEGUN OR END WITHIN PERIOD */
IF ((READTIME_TM > '09:00:00'T AND
READTIME_TM < '16:00:00'T) OR
(TERMTIME_TM > '09:00:00'T AND
TERMTIME_TM < '16:00:00'T))
THEN OUTPUT;
END; |
Thanks & Regards, |
|
Back to top |
|
|
|