What Are Formats in SAS?
Formats in SAS are used to control how data values are displayed rather than how they are stored.
They can be applied in a number of ways, including
isplaying numeric values in a readable way (e.g., currency, percent)
Grouping categories
Formatting dates and times.
FORMAT Syntax:
Format Types : Standard SAS Formats
Date and Time Formats
Numeric Formats
Character Formats
Usually character formats are not displayed like numerics, but you could use formats to assign codes to labels (using user-defined formats).
User Defined Formats
You can create user-defined formats using PROC FORMAT. Formats can create your mapping with values, whether those be numeric or characters.
Sample Code 1: Mapping Codes to Labels
Output:
Sample Code 2: Character Format
Output:
Temporary Vs Permanent Formats
Temporary: Defined in your current SAS session with PROC FORMAT.
Permanent: Saved using a LIBRARY reference allowing you to access it in the future.
To execute or call above command use below code
Viewing and Managing Formats:
List formats:
Remove a format from a variable:
Check applied formats in data dictionary:
Note:
Utilize formats to make reports less complicated in format without impacting the data.
You can combine with PROC FREQ, PROC PRINT, PROC REPORT, etc., to create clearer outputs.
As mentioned above, custom formats are a neat way of grouping continuous data into categories (for example, age bands, scales of income).
Formats in SAS are used to control how data values are displayed rather than how they are stored.
They can be applied in a number of ways, including

Grouping categories
Formatting dates and times.
FORMAT Syntax:
FORMAT variable format.;
- variable is name of the column you want to format.
- format. is name of the format you're applying (with a period).
Format Types : Standard SAS Formats
Date and Time Formats
Format | Example Output | Description |
---|---|---|
DATE9. | 01MAY2025 | Date format (DDMMMYYYY) |
MMDDYY10. | 05/01/2025 | US-style date |
TIME5. | 10:20 | Hours and minutes |
DATETIME20. | 01MAY2025:10:20:00 | Full datetime |
Numeric Formats
Format | Example Output | Description |
---|---|---|
DOLLAR8. | $10,512 | Adds dollar sign and commas |
COMMA6. | 10,512 | Adds comma to large numbers |
PERCENT8. | 55.00% | Multiplies by 100 and adds % |
BEST. | 10.876543 | Best readable format (default) |
Character Formats
Usually character formats are not displayed like numerics, but you could use formats to assign codes to labels (using user-defined formats).
User Defined Formats
You can create user-defined formats using PROC FORMAT. Formats can create your mapping with values, whether those be numeric or characters.
Sample Code 1: Mapping Codes to Labels
proc format;
value genderfmt
1 = 'M'
2 = 'F'
. = 'Miss';
run;
data intellectsage;
input name $ gender;
format gender genderfmt.;
datalines;
Jain 1
Shan 2
Amex .
;
run;
Output:
Sample Code 2: Character Format
proc format;
value $statusfmt
'ACT' = 'Active'
'INACT' = 'Inactive'
'SUS' = 'Suspended';
run;
data intellectsage;
input id $ status $;
format status $statusfmt.;
datalines;
201 ACT
202 INACT
203 SUS
;
run;
Output:
Temporary Vs Permanent Formats
Temporary: Defined in your current SAS session with PROC FORMAT.
Permanent: Saved using a LIBRARY reference allowing you to access it in the future.
libname sage 'C:\formats';
proc format library=sage;
value agegroup
0 - 12 = 'Child group'
13 - 19 = 'Teen group'
20 - high = 'Adult group';
run;
To execute or call above command use below code
options fmtsearch=(sage);
Viewing and Managing Formats:
List formats:
proc format library=intellectsage fmtlib;
run;
Remove a format from a variable:
format varname;
Check applied formats in data dictionary:
proc contents data=intellectsage;
run;
Note:
Utilize formats to make reports less complicated in format without impacting the data.
You can combine with PROC FREQ, PROC PRINT, PROC REPORT, etc., to create clearer outputs.
As mentioned above, custom formats are a neat way of grouping continuous data into categories (for example, age bands, scales of income).