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
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: