BookmarkSubscribeRSS Feed
rahul
Calcite | Level 5

i have date value like 15may2012 i want convert this date to 15may2012:00:00:00 how it will come?

5 REPLIES 5
shivas
Pyrite | Level 9

Hi,

Try this..

data one;

yy=dhms('31MAy2012'd,00,00,00);

format yy datetime.;

run;

Thanks,

Shiva

rahul
Calcite | Level 5

Thank u for u r answer

But you used 15may2012'00'00'00 .but my doubt is only use 15may2012 in input value(informat).and get the value like 15may2012:00:00:00 as format

please be help..

shivas
Pyrite | Level 9

Hi Rahul,

you can also try this...but I will use DHMS function like above to get the datetime format.

data one;

xx='31MAy2012'd;

yy=xx*86400;

format yy datetime.;

run;

If you directly apply format on xx as datetime. then you will different values like 01JAN60:05:19:04

Thanks,

Shiva

Tom
Super User Tom
Super User

If you are reading the value from a text file then use the ANYDTDTM informat.

data _null_;

  input @1 date date9. @1 dt anydtdtm. ;

  format date date9. dt datetime.;

  put (_all_) (=);

cards;

15MAY2012

run;

date=15MAY2012 dt=15MAY12:00:00:00

Alpay
Fluorite | Level 6

İf you already have a date value, 15May2012, stored in a data set but you want to display datetime,15May2012:00:00:00, without changing the value of underlyıng variable you may try picture directives in proc format.

Zafer

proc format;

  pıcture dtfmt low-high = '%d%b%Y:00:00:00' (datatype=date);

run;

data _null_;

  x = '15May2012'd;

  put x dtfmt18.;

run;

15MAY2012:00:00:00

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 5 replies
  • 592 views
  • 0 likes
  • 4 in conversation