BookmarkSubscribeRSS Feed
Avenue
Calcite | Level 5

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

2 REPLIES 2
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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;

sas-innovate-2024.png

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.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 478 views
  • 0 likes
  • 2 in conversation