Help using Base SAS procedures

How to convert date string datetime format

Reply
Frequent Contributor
Posts: 127

How to convert date string datetime format

I have date string  = "20150109103704" How do I  convert it to 09JAN2015:10:37:04

Super User
Super User
Posts: 7,976

Re: How to convert date string datetime format

Hi,

The DHMS() function is probably easiest:

data want;

  orig="20150109103704";

  datet=dhms(input(substr(orig,1,8),yymmdd8.),input(substr(orig,9,2),2.),input(substr(orig,11,2),2.),input(substr(orig,13,2),2.));

  format datet datetime.;

run;

Frequent Contributor
Posts: 127

Re: How to convert date string datetime format

Thanks..

Ask a Question
Discussion stats
  • 2 replies
  • 279 views
  • 0 likes
  • 2 in conversation