Using a User-Defined Format

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 or SPD Engine data set, 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;
The content of the source Employees table is shown in Content of the Source EMPLOYEES Table. The output of the PUT function is shown in Content of the Employees Table After the PUT Function Is Applied.
Content of the Source EMPLOYEES Table
A numeric department code is stored in the DEPT column of the EMPLOYEES table.
Content of the Employees Table After the PUT Function Is Applied
The PUT function applies the numeric format DEPTNO. to change the numeric code values to their corresponding character-based department name.
For more information about how to create your own format in SAS, see PROC FORMAT in Base SAS Procedures Guide.