BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi, all!

when i get the datetime stirng as 'Wed Sep 15 12:28:27 2010', how can i convert it to a datetime variable.
use the NLDATM function, you can give a format descriptor, then can get the datetime part, so, can i use a descriptor as '%a %b %d %H:%M:%S %Y', then can convert the string to a datetime variable?
2 REPLIES 2
polingjw
Quartz | Level 8
Instead of using the NLDATM function, would something like this work?

data _null_;
worddate = 'Wed Sep 15 12:28:27 2010';
numberdate = input(scan(worddate, 3, ' ')!!scan(worddate, 2, ' ')!!scan(worddate, 5, ' ')!!':'!!scan(worddate, 4, ' '), datetime18.);
put 'The SAS date ' numberdate 'is ' worddate;
run;
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
  • 2 replies
  • 1183 views
  • 0 likes
  • 2 in conversation