Convert Date Format

Reply
Occasional Contributor
Posts: 11

Convert Date Format

 

Hi,

 

Below is my output

 

src_systimedate_systimelogtime
28APR2016:14:58:51.00000028apr1614:58:51
28APR2016:14:58:51.00000028apr1614:58:51
28APR2016:14:58:51.00000028apr1614:58:51
28APR2016:14:58:51.00000028apr1614:58:51
28APR2016:14:58:52.00000028apr1614:58:52
28APR2016:14:58:52.00000028apr1614:58:52

 

I want to convert the date format as below

 

 

src_systimedate_systimelogtime
2016-04-28 14:58:512016-04-2814:58:51
2016-04-28 14:58:512016-04-2814:58:51
2016-04-28 14:58:512016-04-2814:58:51
2016-04-28 14:58:512016-04-2814:58:51
2016-04-28 14:58:522016-04-2814:58:52
2016-04-28 14:58:522016-04-2814:58:52
Trusted Advisor
Posts: 1,137

Re: Convert Date Format

data have;
input src_systime : anydtdtm20.	date_systime :date9.	logtime :time8.;
format src_systime  datetime20. 	date_systime date9. logtime time8.;
cards;
28APR2016:14:58:51.000000	28apr16	14:58:51
28APR2016:14:58:51.000000	28apr16	14:58:51
28APR2016:14:58:51.000000	28apr16	14:58:51
28APR2016:14:58:51.000000	28apr16	14:58:51
28APR2016:14:58:52.000000	28apr16	14:58:52
28APR2016:14:58:52.000000	28apr16	14:58:52
;
Thanks,
Jag
Super User
Posts: 7,436

Re: Convert Date Format

Is the "output" a text file or already a SAS dataset?

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Occasional Contributor
Posts: 11

Re: Convert Date Format

Its a SAS dataset only

Trusted Advisor
Posts: 1,137

Re: Convert Date Format

Then, are these variables character type
Thanks,
Jag
Super User
Posts: 7,436

Re: Convert Date Format

[ Edited ]

If these are already SAS datetime, date and time values, you just need the proper formats.

Look at the E8601DT19. format for the datetime value, YYMMDDD10. for the date and TIME8. for the time.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Ask a Question
Discussion stats
  • 5 replies
  • 349 views
  • 1 like
  • 3 in conversation