I've used the following code to convert the date to the format date7. But after executing the code I'm receiving value as *******.
Variable feemisio is a datevalue which has informats datetime23. Example: 21FEB2018:16:54:00
proc print data=temp;
format feemisio date7.;
run;
Appreciate if someone of you help me to resolve the issue.
I guess you have already been told this repeatedly.
You cannot use a date format on a datetime value.
The reason being that datetime values are a count of seconds from 1960-01-01T00:00:00, while date values are a count of days from 1960-01-01.
So, for any given date, the datetime is 86400 * date!
If you want to convert a datetime value to a date value, use the datepart() function in the same step where you assign the date format.
How I can deal this in SAS DI studio without using user written transformation? Will it works if I change only the format for the variable under mapping tab?
If I understand correctly, I need to use the expression like datepart(feemisio) under mapping tab of the target table for the respective variable. Then I will change the format to date7. under format column of the respective variable.
If you want to display just the date part of a datetime value you can use the DTDATE format.
PS. Don't use width of 7. Use a width of 9 (or 11) so that you can see the century part of the year.
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.
Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.
Find more tutorials on the SAS Users YouTube channel.