In an SQL statement I need to have the results returning a custom date format of a field MIS_DATE as YYYY_MM in other words a date like 31JAN2013 being returned as 2013_01. A relevant change in this regard in the following statement shall be obliged:
PROC SQL;
CREATE TABLE RESULTS3 AS SELECT MIS_DATE AS DATA_MONTH format = YYYY_MM. FROM FAQ;
QUIT;
The process runs well without any observation in the Log but when I double click the Results3 dataset the same doesnot open and only then comes up the entry in Log:
ERROR: Format YYYY_MM not found or couldn't be loaded for variable DATA_MONTH.
Thanx in advance.
SAS allows you to build custom date formats using Proc FORMAT, see an example below. Have a look at the doc for the PICTURE statement in Proc FORMAT for more information on other directives possible in a picture format.
See my post in your other thread...
SAS allows you to build custom date formats using Proc FORMAT, see an example below. Have a look at the doc for the PICTURE statement in Proc FORMAT for more information on other directives possible in a picture format.
Sure was an xclent example Bruno!
Highly do oblige your contribution!
If you just want the data as a character string (as opposed to a numeric date value with a particular display format attached to it) then you can build it easily.
select catx('_',year(MIS_DATE),month(MIS_DATE)) as DATA_MONTH
or if you need 2013_01 instead of 2013_1
select catx('_',year(MIS_DATE),put(month(MIS_DATE),Z2.)) as DATA_MONTH
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.