Page 1 of 1

How to Sum Within a partcular Occurance(eg 1:5)

Posted: November 30th, 2024, 1:12 pm
by sham
Hello Family,
I have two time zones in repeat mode, as shown below:

preproc
S3Q1(01)="ACTIVITY1:04:00 to 05:00";
S3Q1(02)="ACTIVITY2:04:00 to 05:00";
S3Q1(03)="ACTIVITY3:04:00 to 05:00";
S3Q1(04)="ACTIVITY4:04:00 to 05:00";
S3Q1(05)="ACTIVITY5:04:00 to 05:00";
S3Q1(06)="ACTIVITY1:05:00 to 06:00";
S3Q1(07)="ACTIVITY2:05:00 to 06:00";
S3Q1(08)="ACTIVITY3:05:00 to 06:00";
S3Q1(09)="ACTIVITY4:05:00 to 06:00";
S3Q1(10)="ACTIVITY5:05:00 to 06:00";

I am collecting data about the total number of minutes for the activities within the time zone 04:00 to 05:00. I want to run a check so that when you sum the total number of minutes reported for the five activities under the time zone 04:00 to 05:00, the total must equal 1 hour (60 minutes). If it is not equal to 60 minutes, it should generate an error.

I have created a total time variable for zone 1 to hold the calculation by summing the minutes for the activities within the zone. However, the calculation did not work. Here's the code I tried:

preproc
TZ1= ACTUAL_MINUTE(1) + ACTUAL_MINUTE(2)+ACTUAL_MINUTE(3) ACTUAL_MINUTE(4)+ACTUAL_MINUTE(5)

I need your help to complete this task. I have attached a sample of the dictionary for better understanding.

Re: How to Sum Within a partcular Occurance(eg 1:5)

Posted: December 2nd, 2024, 3:12 am
by Arjun Brti
Hi sham
You forget to add the + sign in your logic after ACTUAL_MINUTE(3). You can add the total time using your own logic.

preproc
$= ACTUAL_MINUTE(1) + ACTUAL_MINUTE(2)+ACTUAL_MINUTE(3) ACTUAL_MINUTE(4)+ACTUAL_MINUTE(5);

alternately you can use this logic too;

numeric TZ1_total;
TZ1_total = sum(ACTUAL_MINUTE);
$ = TZ1_total;

postproc
if $ > 60 then
errmsg("........................"); reenter S3Q3I(1); endif;

Thank you.

Re: How to Sum Within a partcular Occurance(eg 1:5)

Posted: December 25th, 2024, 5:37 am
by sham
Hi Arjun,
Thank you so much for the support.