Formatting Variable Values |
Lesson
Summary![]() ![]() |
This page contains |
I. Text Summary
To go to the page where a task, programming feature, or concept was presented, select a link. |
Temporarily Formatting Values The FORMAT statement, when used in a SAS procedure, associates a particular format with one or more variables. Formats assigned in this way will remain in effect only for the current processing step. |
Permanently Formatting Values By placing the FORMAT statement in a DATA step, variables are assigned formats permanently. In the Explorer window, display properties for data set columns to see the formats that are assigned to the variables. |
Mixing Temporary and Permanent Formats Formats can be assigned in both the DATA step and in procedures, so that a variable can be given a permanent format but still be displayed in other ways. The formats assigned in a procedure (such as, PROC PRINT) will override permanent formats when the procedure processes. |
Predefined SAS Formats SAS software provides many predefined formats, which are summarized in the online Help system. |
Creating User-Defined Formats The FORMAT procedure allows descriptive values to substitute for the values of coded variables. The LIBRARY= option stores the new formats in a specified format catalog; otherwise, they are stored in a default catalog named WORK.FORMATS. The keyword FMTLIB displays the formats and values that are currently stored in the catalog. The VALUE statement defines a new format for the values of a variable. |
Specifying Values Formats can be specified for a single value, a range of values, or a list of unique values. Unique values should be separated by commas. When character values are specified, the range must be enclosed in quotes and the format name must begin with a dollar sign ($). Non-inclusive numeric ranges can be specified by use of the less than sign (<). The keywords HIGH, LOW, and OTHER can be used to label values not specifically addressed in a range. |
Associating User-Defined Formats with Variables To access the permanent, user-defined formats in a format catalog, you'll need to reference the catalog library by using a LIBNAME statement. To associate user-defined formats with variables in the FORMAT statement, use the same format names in both the FORMAT and VALUE statements, but place a period at the end of the format name when it is used in the FORMAT statement.
|
II. Syntax
To go to the page where a statement or an option was presented, select a link. |
LIBNAME libref 'SAS-data-library'; |
PROC FORMAT LIBRARY=libref FMTLIB; |
VALUE
name range-1='formatted-value-1' < . . . range-n='formatted-value-n' >; |
FORMAT variable
format-name. |
RUN; |
|
III. Sample Program
libname library 'c:\sas\formats\lib'; proc format library=library fmtlib; value JobFmt 103='manager' 105='text processor'; run; 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;
|
IV. Points to Remember
|
![]() ![]() ![]() ![]() ![]() |
|
![]() |
![]() |
Copyright © 2002 SAS Institute Inc., Cary, NC, USA. All rights reserved.