SAS OnlineTutor HomeFAQ PageSuggested Learning PathsContents+Searchback||next

Formatting Variable Values
Associating User-Defined Formats with Variables


When associating a format with a variable, remember to
  • use the same format name in the FORMAT statement that you specified in the VALUE statement
  • place a period at the end of the format name when it is used in the FORMAT statement.

     libname library 'c:\sas\formats\lib';
     proc format lib=library;
        value JobFmt
              103='manager'
              105='text processor'
              111='assoc. technical writer'
              112='technical writer'
              113='senior technical writer';
     run;

     libname library 'c:\sas\formats\lib';
     data perm.empinfo;
        infile empdata;
        input @9 FirstName $5. @1 LastName $7. +7 JobTitle 3.
              @19 Salary comma9.;
        format salary comma9.2 jobtitle jobfmt.;
     run;

If you choose not to format all of a variable's values, those in the VALUE statement are printed with the specified format; the remaining values are printed as they appear in the SAS data set. For example,

     proc format lib=library;
        value JobFmt
           103='manager'
           105='text processor';
     run;

Obs FirstName LastName JobTitle Salary
1 Donny Evans 112 29996.63
2 Lisa Helms text processor 18567.23
3 John Higgins 111 25309.00
4 Amy Larson 113 32696.78
5 Mary Moore 112 28945.89
6 Jason Powell manager 35099.50
7 Judy Riley 111 25309.00



back||next


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

Terms of Use & Legal Information | Privacy Statement