BookmarkSubscribeRSS Feed
laxmanpai
Calcite | Level 5

Hi,

 

I am having an input '05AUG2019:09:00:00.000000' which is to be formatted to

                          2019-08-05:09:00:00.000000

 

i am using below code to achieve this but it returns me "ERROR" in the column.

 

proc format ;

picture mdyhms other = '%Y-%0m-%0d %0H:%0M:%0S.000000' (datatype=datetime);

 

 

 

 

4 REPLIES 4
Kurt_Bremser
Super User

Read with the DATETIME informat, and assign your display format:

proc format ;
picture mdyhms other = '%Y-%0m-%0d %0H:%0M:%0S.000000' (datatype=datetime);
run;

data test;
invar = '05AUG2019:09:00:00.000000';
outvar = input(invar,datetime25.);
format outvar mdyhms.;
run;
PaigeMiller
Diamond | Level 26

So wait a minute here

 


@laxmanpai wrote:

 

I am having an input '05AUG2019:09:00:00.000000'


You have a character string that looks like 05AUG2019:09:00:00.00000? You can't format a character string that way. You'd have to convert it to numeric first. Then you should be able to use the E8601DTw.d format

 

But before I come up with code to do this, please confirm that you mean you really do have a character string.

--
Paige Miller
laxmanpai
Calcite | Level 5

Hi, 

The input is coming from Oracle Timestamp(6) column and i am reading it from SAS EG.

The Actual data is in format 3/19/2018 12:53:09.000000 PM

i want the data to be displayed as 2018-03-19 12:53:09.000000

If i dont use any format function it is being read as "Timestamp Not Recognized" while trying to load into Snowflake .

 

 

 

 

Ksharp
Super User
If it was
05AUG2019:09:00:00.999999
how to display this datetime ?

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1388 views
  • 1 like
  • 4 in conversation