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

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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