Lesson 9: The Format Procedure

Overview Section

We previously learned how to use a FORMAT statement to tell SAS to display certain variable values in a particular way. For example, we might tell SAS to display a date variable saledate, say, using the SAS mmddyy10. format, so that August 19, 2008 is displayed as 08/19/2008. There are a whole slew of informats and formats that SAS provides that you can find in the SAS Help and Documentation. Our focus in this lesson will be on creating informats and formats to fill in for those that SAS doesn't provide.

That is, in this lesson, we will extend our formatting capabilities by investigating how to create user-defined informats and formats using the FORMAT procedure. In particular, we will take a look at the following techniques:

  • how to translate values of a character variable when they are read in a SAS data set into more meaningful values using the INVALUE statement
  • how to create customized formats for character and numeric variables, using the VALUE statement, so variables can be printed in a meaningful format
  • how to create templates, using the PICTURE statement, for printing numbers with a special format, such as leading zeros, decimal and comma punctuation, fill characters, and prefixes.


Upon completion of this lesson, you should be able to:

Upon completing this lesson, you should be able to do the following:

  • use a PUT statement to create an ascii file from a SAS data set
  • use an INVALUE statement in the FORMAT procedure to tell SAS how to read in special characters
  • associate a character variable with a particular informat
  • create a permanent formats catalog for a SAS data set
  • use a VALUE statement in the FORMAT procedure to tell SAS how to print certain variables
  • use a format to define categories
  • use the NOFMTERR option to use a data set with permanently formatted variables without having access to the formats catalog
  • use the %INCLUDE statement to include a secondary program file in a main SAS program
  • use a codebook to help define formats
  • use a PICTURE format to to create templates for printing numbers by defining a format that allows for special characters
  • use the FMTLIB option of the FORMAT procedure to tell SAS to print the contents of a formats catalog.