Hi Guys,
I have a numeric date like: 140731.
I will like to convert this to something like this: 20140731000000. Notice that there are six zeros added to the date.
Thanks
Not sure what you want it for, if its just a text string then:
data have;
attrib mydate format=yymmdd6.;
mydate='31JUL2014'd;
run;
data want;
set have;
attrib char_date format=$200.;
char_date=compress(put(mydate,yymmdd10.),"-")||"000000";
run;
Alternatively you could look at ISO dates/formats, though those have additional characters in them.
Just to add an example of the ISO dates:
data have;
attrib mydate format=yymmdd6.;
attrib mynewdate format=e8601dt19.;
attrib textver format=$20.;
mydate='31JUL2014'd;
mynewdate=input(put(mydate,yymmdd10.)||"T00:00:00",e8601dt19.);
textver=compress(put(mynewdate,e8601dt19.),"T:- ");
run;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.