BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
buddha_d
Pyrite | Level 9
SAS community,
Input is like this
16JUN16:10:30:55 (properties: Length 8, Type Numeric, format datetime16.)


Output should look like
6/16/2016 10:30:55 AM (properties: length 22, Type character, don't know format & informants for this).

I tried proc format with picture (was suggested by ballardw, worked with windows sas, but this stupid saseg is giving error that it doesn't recognize anydtdtm. Informat).

SAS gurus please help.
1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

Don't know why your code that runs in base wouldn't run in EG. However, the following should work in both:

 

data have;
  input dt datetime18.;
  format dt datetime18.;
  cards;
16JUN16:10:30:55
;

proc format library=work;
  picture Exceldt (default=22)
  low-high = '%0m/%0d/%Y %h:%0M:%0S %p' (datatype=datetime);
run;

data want;
  set have;
  char_dt=put(dt,Exceldt.);
run;

Art, CEO, AnalystFinder.com

 

View solution in original post

3 REPLIES 3
art297
Opal | Level 21

Don't know why your code that runs in base wouldn't run in EG. However, the following should work in both:

 

data have;
  input dt datetime18.;
  format dt datetime18.;
  cards;
16JUN16:10:30:55
;

proc format library=work;
  picture Exceldt (default=22)
  low-high = '%0m/%0d/%Y %h:%0M:%0S %p' (datatype=datetime);
run;

data want;
  set have;
  char_dt=put(dt,Exceldt.);
run;

Art, CEO, AnalystFinder.com

 

kiranv_
Rhodochrosite | Level 12

this should do

proc format;

picture mydate other='%0m/%0d/%0Y %0H:%0M:%0S %p' (datatype=datetime);

run;

data a;

a= '16JUN16:10:30:55';

b= input(a, datetime.);

format b mydate.;

run;

 

buddha_d
Pyrite | Level 9
Thanks Art, it worked finally. I appreciate your prompt response. Thank you

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
  • 3 replies
  • 879 views
  • 0 likes
  • 3 in conversation