Return to Archive

SAS Tip of the Month
September 2004

Your program has a variable that is coded as 1=YES and 2=NO with an associated format called YN. Now there is a new value of 3=DON'T KNOW in your data but the format YN has not been changed. In your reporting program you can create another format, in this example YNX, using the following code:

   proc format;
      value ynx
         1='YES'
         2='NO'
         3="DON'T KNOW";
   run;

A better way though, avoiding transcription problems, is to make the new YNX format by nesting the old format YN into the new as shown in the following code:

   proc format;
      value ynx
         3="DON'T KNOW"
         other=[yn.];
   run;

Note that you must enclose the existing format name in square brackets, as shown above, or with parentheses and vertical bars, for example (|yn.|).

________________________________
Updated September 3, 2004