To format a date in SAS like ddmmmyyyy, you can use the date9. date format.
data example;
d = "15sep2022"d;
put d date9.;
run;
// Log Output:
15SEP2022
When working with different variables in SAS, the ability to change formats easily is valuable.
One such case is if you have a date and want to format it differently.
A common date format which is commonly used in real world applications is showing a date like ddmmmyyyy.
To format a date like ddmmmyyyy in SAS, you can use the datew. date format. To get a date like ddmmmyyyy, you can use date9.
Below shows you how to format a date with the date9. date format in SAS.
data example;
d = "15sep2022"d;
put d date9.;
run;
// Log Output:
15SEP2022
Formatting a Date in SAS like ddmmmyyyy with datew.
You can use the datew. format to format dates like ddmmmyyyy with two other widths.
Two other date formats which might make sense are date8. and date11.
Below shows you how to format a date with the date8. and date11. in a SAS data step.
data example;
d = "15sep2022"d;
put d date8.;
put d date9.;
put d date11.;
run;
// Log Output:
15SEP22
15SEP2022
15-SEP-2022
Hopefully this article has been useful for you to learn how to format a date in SAS like ddmmmyyyy.