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.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Lock in the best rate now before the price increases on April 1.
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.