Format dates and years in SAS
How SAS date formats such as YEAR4., YYMMDD10. and MMDDYY10. change what you see without changing the stored value, and when a four-digit year format suits your output.
People who search for a SAS "yyyy format" usually want a date to show as a four-digit year, or as a full date that starts with the year. SAS has no format named YYYY. The same result comes from built-in formats such as YEAR4., YYMMDD10. and YYMMDDN8., or from a custom picture format. This review covers what these formats change, when each one fits, and what can go wrong once formatted dates leave SAS.
What a SAS date format actually changes
A SAS date value is a number: the count of days since January 1, 1960. A format is a display rule applied to that number. Assigning YEAR4. or YYMMDD10. to a variable changes how the value prints in logs, reports and most exports. The stored number stays the same, so date arithmetic, comparisons and sorting still use the underlying day count.
In SAS, "format" does not mean a font or visual styling. It is a rule that turns a stored value into display text. The stored value changes only when you create a new variable. The PUT function converts the date into a character string. The YEAR function extracts the year as a new number.
data example;
d = '31OCT2026'd; /* numeric date value */
format d yymmdd10.; /* display rule only */
year_num = year(d); /* new numeric variable: 2026 */
year_txt = put(d, year4.); /* new character variable: "2026" */
run;
After this step, d is still numeric and displays as 2026-10-31. year_num is a number you can calculate with. year_txt is text, so it will not take part in date arithmetic unless you convert it back.
Common formats for showing the year
| Format | Display of October 31, 2026 | Typical use |
| YEAR4. | 2026 | Year only, e.g. grouping or labeling by year |
| YYMMDD10. | 2026-10-31 | Year-first date with hyphen separators |
| E8601DA10. | 2026-10-31 | ISO 8601 date, explicit about the standard |
| YYMMDDN8. | 20261031 | Compact year-first date with no separators, often used in file names |
| MMDDYY10. | 10/31/2026 | Conventional US month/day/year display |
| DATE9. | 31OCT2026 | Common SAS default style; month name avoids day/month confusion |
The number in each format name is the display width. A width that is too small can truncate the output or fall back to a shorter form. YEAR2., for example, shows only two digits of the year. Use widths that leave room for a four-digit year when the full year matters.
If no built-in format matches the layout you need, PROC FORMAT can define a picture format that uses date directives. In the example below, %Y is the four-digit year and %0m and %0d are the zero-padded month and day.
proc format;
picture ymd_slash (default=10)
low-high = '%Y/%0m/%0d' (datatype=date);
run;
Is a four-digit year format suitable for your use?
For most reporting and data exchange, a format that shows all four digits of the year is the safer choice. It removes any guess about the century and makes the output easier to read. Year-first layouts such as YYMMDD10. or E8601DA10. have a further advantage: once they become text, they still sort in chronological order.
The main tradeoff is between familiarity and ambiguity. US readers expect month/day/year, so MMDDYY10. reads naturally in a domestic report. However, 10/11/2026 means different dates to readers who expect day/month order. When the audience is mixed, or the output feeds another system, a year-first ISO-style date avoids that problem.
Leave the date unformatted, or keep a separate plain numeric copy, when the next step is calculation inside SAS. Do the same when a downstream program expects the raw SAS day count. Formatting only for display is fine. Converting to character with PUT too early makes later date logic harder.
Datetime values need different handling
A SAS datetime value counts seconds, not days. Applying a date format such as YEAR4. to a datetime variable treats seconds as days and produces wrong or invalid output. Use DATEPART to extract the date first, or apply a datetime format such as DTYEAR. or DTDATE9. directly.
Reading years correctly on input
Formats control output. Informats control how text is read into date values. When incoming data contains two-digit years, the YEARCUTOFF= system option decides which century SAS assigns. The default has differed across SAS releases, so check the setting in your own session, for example with PROC OPTIONS, rather than assuming it.
Flexible informats such as ANYDTDTE. accept many layouts. For ambiguous strings like 03/04/2026, they rely on the DATESTYLE= option to choose between month-first and day-first order. Reading four-digit, year-first source data avoids both issues.
Will formatted dates stay usable after export or sharing?
- Exports: many export paths write formatted values, but confirm what your specific procedure and destination produce. A missing format can leave a bare day count that means nothing outside SAS.
- Spreadsheets: spreadsheet software may reinterpret date-like text using its own locale settings. That can swap day and month or change the display. Year-first ISO dates are less prone to this, but no source here confirms behavior for a particular application.
- Sorting as text: year-first strings such as 2026-10-31 sort correctly. Month-first strings such as 10/31/2026 do not sort chronologically once they are character values.
- Search and filtering: a reader searching for "2026" will find it in YEAR4., YYMMDD10. or MMDDYY10. output, but not in YEAR2. output.
- Editing: a formatted numeric date stays a date when edited in SAS. A PUT-converted character copy does not. If you edit the text, re-read it with an informat before using it in date logic.
Locale-sensitive formats in the NLDATE family adapt month names and ordering to the LOCALE= system option. They suit localized reports, but the same code can produce different text in sessions with different locale settings. Choose them deliberately, not as a general default.
Accessibility and evidence gaps
The supplied material contains no tests of how screen readers or other assistive technologies announce different SAS date layouts in exported files or reports. Numeric-only forms such as 20261031 are plausibly harder to interpret by ear than forms with separators or month names, but that is unverified here. Where accessibility matters, test the output in the specific destination and assistive technology you plan to use. Including a month name, as DATE9. or a worded NLDATE format does, is one option to evaluate.
Bottom line
To show a four-digit year in SAS, apply YEAR4. for the year alone, or YYMMDD10. or E8601DA10. for a full year-first date. Keep the underlying value numeric. Use PUT or YEAR only when you need a separate text or numeric copy. Reserve MMDDYY10. for audiences that expect US ordering, and check how your export destination handles the result before relying on it.