Custom formats, also known as user defined formats, can be created and used like any other default formats.
/*Create new character format for state variables*/
PROC FORMAT;
VALUE $statef 'CA' = 'California'
'MA' = 'Massachusetts'
'NY' = 'New York';
/*Once created, you can use your custom format in PROC and DATA steps*/
PROC PRINT DATA=table;
FORMAT state-var $statef.;
RUN;
The variable state-var
will be printed according to the new format. For example, the value 'CA'
will be printed as 'California'
. If a value was not formatted, such as 'CT'
, then that value will be printed as it appears in the data set.