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.
If you have not already done so, open the Hurricanes
data set.
Select
→ from the main menu.The Variable Transformation Wizard appears, as shown in Figure 12.8.
Select
from the list and click .The second page of the wizard provides a window where you can enter DATA step statements.
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 */
Click
.
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.)