Part 1: Create an Indicator Variable

Using the DATA step is an easy way to create a variable that enumerates the observations for each cyclone. The following steps use the Variable Transformation Wizard to create the indicator variable. See Custom Transformations for details about the Variable Transformation Wizard.

  1. If you have not already done so, open the Hurricanes data set.

  2. Select AnalysisVariable Transformation from the main menu.

    The Variable Transformation Wizard appears, as shown in Figure 12.8.

    Figure 12.8: Selecting a Custom Transformation


  3. Select Custom from the Family list and click Next.

    The second page of the wizard provides a window where you can enter DATA step statements.

  4. Type in the following DATA step statements, prior to the RUN statement, as shown in Figure 12.9.

       by name notsorted;
       if first.name then Count=0;
       Count+1; /* implicitly RETAINS the Count value */
    

    Figure 12.9: Entering DATA Step Code


  5. Click Finish.

A new variable, Count, is added to the data table. The variable enumerates the observations for each cyclone. In particular, Count=1 indicates the first observation for each cyclone. Figure 12.10 shows the new variable. (Some variables in the table are hidden.)

Figure 12.10: Hurricane Data With a New Variable