Hi,
I want the following sas date format: YYYY-MM-DD
Can someone help to achieve this?
Thanks.
Two display formats exist that display SAS date values (counts of days, where 1960-01-01 is day zero) in this manner: YYMMDDD10. or E8601DA10.
If you have to start with something that looks like a date, but is not yet a SAS date value, please tell us the type (numeric or character) and the current format attached to the variable.
Two display formats exist that display SAS date values (counts of days, where 1960-01-01 is day zero) in this manner: YYMMDDD10. or E8601DA10.
If you have to start with something that looks like a date, but is not yet a SAS date value, please tell us the type (numeric or character) and the current format attached to the variable.
First, bookmark this link:
SAS® 9.4 and SAS® Viya® 3.4 Programming Documentation
From there, open Data Step Programming to find the chapters dealing with Formats/Informats, Functions/Call Routines, and other DATA step related information. The Dictionary of Formats offers to find Formats by Category, so you get a place where to start looking for date formats.
Hi KurtBremser, I think you mistyped the format YYMMDD10. as YYMMDDD10. (extra D). Isn't it?
@LeonidBatkhan wrote:
Hi KurtBremser, I think you mistyped the format YYMMDD10. as YYMMDDD10. (extra D). Isn't it?
No. The extra "D" instructs SAS to use the dash as delimiter (default is a forward slash). See here.
Hi KurtBremser,
Interesting. I run
data _null_;
d='30jul2020'd;
put d= yymmdd10.;
run;
(without extra d) and it gives me the date with hyphens:
d=2020-07-30
Apparently in the YYMMDDxw. Format default (when x is not present) is hyphen.
You're right. I don't know how I came to use the YYMMDDD format; maybe I confused it with MMDDYY, where the slash is default.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.