Defining a Dynamic Global Window With SET

This topic illustrates the creation of a dynamic window using the global command SET YRTHRESH. You can also implement this feature on the file and field level, and on a DEFINE or COMPUTE.

With this option of the sliding window technique, the start year and threshold for the window automatically changes at the beginning of each new year. The default century (DEFCENT) is automatically calculated.

You can use SET TESTDATE to alter the system date when testing a dynamic window (that is, when YRTHRESH has a negative value). However, when testing a dynamic window defined in a Master File, you must issue a CHECK FILE command each time you issue a SET TESTDATE command. CHECK FILE reloads the Master File into memory and ensures the correct recalculation of the start date of the dynamic window. For details on SET TESTDATE, see your documentation on the SET command. For details on CHECK FILE, see the Describing Data manual.

Example: Defining a Dynamic Global Window With SET

In the following request, the COMPUTE command calls the function AYMD, supplied by Information Builders. AYMD adds one day to the input field, HIRE_DATE; the output field, HIRE_DATE_PLUS_ONE, contains the result. HIRE_DATE is formatted as I6YMD, which is a legacy date with a 2-digit year. HIRE_DATE_PLUS_ONE is formatted as I8YYMD, which is a legacy date with a 4-digit year.

The function uses the YRTHRESH value set at the beginning of the request to create a dynamic window for the input field HIRE_DATE. The start date of the window is incremented by one at the beginning of each new year. Notice that DEFCENT is not coded, since the default century is automatically calculated whenever YRTHRESH has a negative value.

The function inputs a 2-digit year, which is windowed. It then outputs a 4-digit year that includes the century digits.

Sample values are shown in the reports for 1999, 2000, and 2018, which follow the request.

For details on AYMD, see the Using Functions manual.

The request is:

SET YRTHRESH = -18 
 
TABLE FILE EMPLOYEE 
PRINT HIRE_DATE AND COMPUTE
      HIRE_DATE_PLUS_ONE/I8YYMD = AYMD
      (HIRE_DATE, 1, HIRE_DATE_PLUS_ONE);
END

In 1999, the window spans the years 1981 to 2080. The threshold is 81 (1999 - 18). In the report, the 2-digit year 80 is less than the threshold 81, so it assumes the value 20 for the century (DEFCENT + 1), and is returned as 2080 in the HIRE_DATE_PLUS_ONE column. The other year values (81 and 82) are greater than or equal to the threshold 81, so the century defaults to the value of DEFCENT (19); they are returned as 1981 and 1982.

The output is:

PAGE     1
 
HIRE_DATE   HIRE_DATE_PLUS_ONE
---------   ------------------
 80/06/02           2080/06/03
 81/07/01           1981/07/02
 82/05/01           1982/05/02
 82/01/04           1982/01/05
 82/08/01           1982/08/02
 82/01/04           1982/01/05
 82/07/01           1982/07/02
 81/07/01           1981/07/02
 82/04/01           1982/04/02
 82/02/02           1982/02/03
 82/04/01           1982/04/02
 81/11/02           1981/11/03

In 2000, the window spans the years 1982 to 2081. The threshold is 82 (2000 - 18). In the report, the 2-digit years 80 and 81 are less than the threshold; for the century, they assume the value 20 (DEFCENT + 1). The 2-digit year 82 is equal to the threshold; for the century, it defaults to the value 19 (DEFCENT).

The output is:

PAGE     1
 
HIRE_DATE   HIRE_DATE_PLUS_ONE
---------   ------------------
 80/06/02           2080/06/03
 81/07/01           2081/07/02
 82/05/01           1982/05/02
 82/01/04           1982/01/05
 82/08/01           1982/08/02
 82/01/04           1982/01/05
 82/07/01           1982/07/02
 81/07/01           2081/07/02
 82/04/01           1982/04/02
 82/02/02           1982/02/03
 82/04/01           1982/04/02
 81/11/02           2081/11/03

Running the report in 2018 illustrates the automatic recalculation of DEFCENT from 19 to 20. In 2018, the window spans the years 2000 to 2099. The threshold is 0 (2018 - 18). A 2-digit year greater than or equal to 0 defaults to the recalculated value 20 (DEFCENT).

Since all the values for the HIRE_DATE year are greater than 0, the century defaults to 20.

The output is:

PAGE     1
 
HIRE_DATE   HIRE_DATE_PLUS_ONE
---------   ------------------
 80/06/02           2080/06/03
 81/07/01           2081/07/02
 82/05/01           2082/05/02
 82/01/04           2082/01/05
 82/08/01           2082/08/02
 82/01/04           2082/01/05
 82/07/01           2082/07/02
 81/07/01           2081/07/02
 82/04/01           2082/04/02
 82/02/02           2082/02/03
 82/04/01           2082/04/02
 81/11/02           2081/11/03

Information Builders