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.
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: