How can I add the OTHER range to format when creating a format with the CNTLIN= option?


In order to add the OTHER range, the variable HLO must be set to 'O'. The variable HLO's value denotes a special range in an input control data set. The 'O' (an uppercase o) denotes the special range of OTHER. Here is a simple example:

DATA ONE;
  INPUT X Y $;
CARDS;
1 BLUE
2 RED
;
RUN;

/*This example uses the END= option to determine when the end of the input data set has been reached. When the last observation has been read, the DO loop will write out one more observation , setting the value of HLO to 'O' and assigning the LABEL for the values of the OTHER range*/

DATA TWO;
  LENGTH LABEL $ 20; 
  SET ONE END=LAST;
  FMTNAME='COLORS';
    START=X;
    LABEL=Y;
    OUTPUT;
  IF LAST THEN DO;
    HLO='O';
    LABEL='UNKNOWN COLOR';
    OUTPUT;
   END;
  RUN;
 
  PROC PRINT;
  RUN;
  PROC FORMAT CNTLIN=TWO FMTLIB;
  RUN;