Hello,
How to format datetime to CCYYMMDD_HHMM? I can cat a string for YYMMDD_HHMM, but I have no idea about CC (century). Would I have any idea from you?
Thank you!
Yvonne
Create a picture format using the required directives to produce the result you want. You can then either format the existing column, or create a character string using the PUT statement.
proc format;
picture dtfmt low-high = '%Y%0m%0d_%0H%0M'
(datatype=datetime);
run;
data want;
a='18jul2012:08:50'dt;
format a dtfmt.;
b=put(a,dtfmt.);
run;
What is your sample data and output you need ?
system time, such as today()
I agree with Keith. Additionally, you probably want to use datetime() rather than today() if you want hours and minutes as well as date.
I am not sure if understand your question. For example 'today', 20120718, '20' marks CC(century), '12' marks YY, etc. What is the question then? If you are asking why '20' denotes 21st century, well that is way it is, as it started out as 1st instead of 0th century (A.D).
Haikuo
Thank you all for helping me. Hai.Kuo is right that YYYY = CCYY.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.