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

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