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.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.