SAS OnlineTutor HomeFAQ PageSuggested Learning PathsContents+Searchback||next

Formatting Variable Values
Creating User-Defined Formats


Now, any format you create in this PROC FORMAT step is stored in a permanent format catalog called Library.Formats.

  
     libname library 'c:\sas\formats\lib';
     proc format library=library
        . . .;
     run;
In the program above, the catalog Library.Formats is located in the SAS library C:\Sas\Formats\Lib, which is referenced by the libref Library.

Notice that LIB= is an acceptable abbreviation for the LIBRARY= option.

     proc format lib=library;

Also notice that you can specify a catalog name in the LIBRARY= option, and store formats in any catalog you want. The catalog name must adhere to SAS naming conventions.

     proc format lib=library.catalog;

Now that you know how to store your own formats, let's see how to create them.


Defining a Unique Format

The VALUE statement defines a format for displaying one or more values.


General form, VALUE statement:
VALUE name range-1='label-1'
<...range-n='label-n'>;

where the format's name

  • must begin with a dollar sign ($) if it applies to a character variable, and it cannot be longer than eight characters
  • cannot be the name of a SAS format
  • cannot end with a number
  • does not end in a period when specified in a VALUE statement.


Notice that the statement begins with the keyword VALUE and ends with a semicolon after all the labels have been defined. For example, this single VALUE statement creates the JobFmt format, which assigns a label to each possible value for the variable JobTitle.
     proc format lib=library;
        value JobFmt
           103='manager'
           105='text processor'
           111='assoc. technical writer'
           112='technical writer'
           113='senior technical writer';
     run;

FirstName LastName JobTitle Salary
Donny Evans 112 29996.63
Lisa Helms 105 18567.23
John Higgins 111 25309.00
Amy Larson 113 32696.78
Mary Moore 112 28945.89
Jason Powell 103 35099.50



back||next


Copyright © 2002 SAS Institute Inc., Cary, NC, USA. All rights reserved.

Terms of Use & Legal Information | Privacy Statement