Return to Homepage

Goto the Tip of the Month Archive

Other interesting pages ...
LinkedIn Profile
SAS Cheat Sheet
Useful SAS Code
Full SAS Example
Basic Statistics
Contact Information

SAS Tip of the Month
July 2014
(for SAS)

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.|).

Hope this is useful. See you next month.

________________________________
Updated July 2, 2014