Hi all,
I currently have the date (varname: serv_date) presented in the format of (DDMMMYYYY HH:MM:SS). Currently, I'm trying to reformat it so that the table would only contain ddmmmyyyy.
I've tried some solutions such as ...
proc sql; create table test as select serv_date format = date9. from plastics_fnl; quit;
But the output is quite odd and unexpected.
May someone help identify a solution as well as explain what went wrong in the code I provided?
How about
proc sql;
create table test as
select datepart(serv_date) as serv_date format = date9.
from plastics_fnl;
quit;
How about
proc sql;
create table test as
select datepart(serv_date) as serv_date format = date9.
from plastics_fnl;
quit;
If a value is a SAS datetime value then the units are SECONDS, if a date then the units are DAYS. So you cannot use a date9 format to display datetime. If you assign a datetime9. format then that will appear similar to a date9 format.
OR use the datepart(dtvariable) function to create date value.
You don't need to create a new date variable. All you need to do is assign the DTDATE format.
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.