Defining a Global Window With SET

How to:

The SET DEFCENT and SET YRTHRESH commands define a window on a global level. The time span created by the SET commands applies to every 2-digit year used by the application unless you specify file-level or field-level windows elsewhere.

For details on specifying parameters that govern the environment, see Customizing Your Environment.

Syntax: How to Define a Global Window With SET

To define a global window, issue two SET commands.

The first command is

SET DEFCENT = {cc|19}

where:

cc

Is the century for the start date of the window. If you do not supply a value, cc defaults to 19, for the twentieth century.

The second command is

SET YRTHRESH = {[-]yy|0}

where:

yy

Is the year threshold for the window. If you do not supply a value, yy defaults to zero (0).

If yy is a positive number, two-digit years greater than or equal to the threshold default to the value of FDEFCENT for the century. Two-digit years less than the threshold assume the value of FDEFCENT + 1.

If yy is a negative number (-yy), the start date of the window is derived by subtracting that number from the current year, and FDEFCENT is automatically calculated. The start date is automatically incremented by one at the beginning of each successive year.

Example: Defining a Global Window With SET

In the following request, the SET command defines a global window from 1983 to 2082.

As SET syntax allows, the command is entered on one line, with the parameters separated by a comma. You do not need to repeat the keyword SET for YRTHRESH.

The DEFINE command converts the legacy date EFFECT_DATE into the date format NEW_DATE. It creates NEW_DATE as a virtual field, derived from the existing field EFFECT_DATE. The format of EFFECT_DATE is I6YMD, which is a 2-digit year. NEW_DATE is formatted as YYMD, which is a 4-digit year. For details on DEFINE, see the Creating Reports manual.

The request is:

SET DEFCENT = 19, YRTHRESH = 83 
 
DEFINE FILE EMPLOYEE 
NEW_DATE/YYMD = EFFECT_DATE; 
END 
 
TABLE FILE EMPLOYEE 
PRINT EFFECT_DATE NEW_DATE BY EMP_ID 
END

In the report, the value of the 2-digit year 82 is less than the threshold 83, so it assumes the value 20 for the century (DEFCENT + 1) and is returned as 2082 in the NEW_DATE column. The other year values (83 and 84) are greater than or equal to the threshold 83, so the century defaults to the value 19 (DEFCENT); they are returned as 1983 and 1984 under NEW_DATE.

The output is:

PAGE     1
 
EMP_ID     EFFECT_DATE   NEW_DATE
------     -----------   --------
071382660
112847612
117593129     82/11/01   2082/11/01
119265415
119329144     83/01/01   1983/01/01
123764317     83/03/01   1983/03/01
126724188
219984371
326179357     82/12/01   2082/12/01
451123478     84/09/01   1984/09/01
543729165
818692173     83/05/01   1983/05/01

In the example, missing date values appear as blanks by default. To retrieve the base date value for the NEW_DATE field instead of blanks, issue the command

SET DATEDISPLAY = ON

before running the request.

The base date value for NEW_DATE, which is formatted as YYMD, is returned as 1900/12/31:

PAGE     1
 
EMP_ID     EFFECT_DATE   NEW_DATE
------     -----------   --------
071382660                1900/12/31
112847612                1900/12/31
117593129     82/11/01   2082/11/01
119265415                1900/12/31
119329144     83/01/01   1983/01/01
123764317     83/03/01   1983/03/01
126724188                1900/12/31
219984371                1900/12/31
326179357     82/12/01   2082/12/01
451123478     84/09/01   1984/09/01
543729165                1900/12/31
818692173     83/05/01   1983/05/01

If NEW_DATE had a YYM format, the base date would appear as 1901/01. If it had a YYQ format, it would appear as 1901 Q1.

If the value of NEW_DATE is 0 and SET DATEDISPLAY = OFF (the default), blanks are displayed. With SET DATEDISPLAY = ON, the base date is displayed instead of blanks. Zero (0) is treated as an offset from the base date, which results in the base date.

For details on SET DATEDISPLAY, see Customizing Your Environment.


Information Builders