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.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.