You can use the SAS
FORMAT procedure to define custom formats that replace raw data values
with formatted character values. For example, the following PROC FORMAT
code creates a custom numeric format called DEPTNO. that maps department
codes to their corresponding department name.
proc format;
value deptno
10 = 'Sales'
20 = 'Research'
30 = 'Accounting'
40 = 'Operations';
run;
The resulting user-defined
format can be stored in a SAS data set, SPD Engine data set, or SPD
Server table, or it can be applied to a third-party data source by
using the PUT function. The following code uses the PUT function and
DEPTNO. format to change the numeric department codes in the DEPT
column of the EMPLOYEES table to their corresponding character-based
department name.
select emp_name, hire_date, put(dept, deptno.) as dept
from employees limit 4;
quit;
For more information
about how to create your own format in SAS, see PROC FORMAT in Base SAS Procedures Guide.