Creating Time ID Variables


Creating a Time ID from Other Dating Variables

Your data set might contain ID variables that date the observations in a different way than the SAS date valued ID variable expected by the forecasting system. For example, for monthly data, the data set might contain the ID variables YEAR and MONTH, which together date the observations.

In these cases, you can use the Forecasting System’s Create Time ID features to compute a time ID variable with SAS date values from the existing dating variables. As an example of this, use the SAS data set read in by the following SAS statements:

   data id_parts;
      input yr qtr y;
   datalines;
    91 1 10
    91 2 15
    91 3 20
    91 4 25
    92 1 30
    92 2 35
    92 3 40
    92 4 45
    93 1 50
    93 2 55
    93 3 60
    93 4 65
    94 1 70
    94 2 75
    94 3 80
    94 4 85
   run;

Submit these SAS statements to create the data set ID_PARTS. This data set contains the three variables YR, QTR, and Y. YR and QTR are ID variables that together date the observations, but each variable provides only part of the date information. Because the forecasting system requires a single dating variable containing SAS date values, you need to combine YR and QTR to create a single variable DATE.

Type "ID_PARTS" in the Data Set field and press the ENTER key. (You could also use the Browse button to open the Data Set Selection window, as in the previous example, and complete this example from there.)

Select the Create button at the right of the Time ID field. This opens the menu of Create Time ID choices, as shown in Figure 55.8.

Figure 55.8: Adding a Time ID Variable

Adding a Time ID Variable


Select the second choice, Create from existing variables. This opens the window shown in Figure 55.9.

Figure 55.9: Creating a Time ID Variable from Date Parts

Creating a Time ID Variable from Date Parts


In the Variables list, select YR. In the Date Part list, select YEAR as shown in Figure 55.10.

Figure 55.10: Specifying the ID Variable for Years

Specifying the ID Variable for Years


Now click the right-pointing arrow button. The variable YR and the part code YEAR are added to the Existing Time IDs list.

Next select QTR from the Variables list, select QTR from the Date Part list, and click the arrow button. This adds the variable QTR and the part code QTR to the Existing Time IDs list, as shown in Figure 55.11.

Figure 55.11: Creating a Time ID Variable from Date Parts

Creating a Time ID Variable from Date Parts


Now select the OK button. This opens the New Data Set Name window. Change the New data set name field to NEWDATE, and then select the OK button.

The data set NEWDATE is created, and the system returns to the Time Series Forecasting window with NEWDATE as the selected Data Set. The Time ID field is set to DATE, and the Interval field is set to QTR.