data sample ;
val_num = 20180102030405 ;
val_char = "20180102030405";
run ;
data sample2 ;
set sample ;
/* num to sas datetime */
format val_date datetime20.;
val_date = input(put(val_num, 14.), B8601DN.);
/* char to sas datetime */
date = input(substr(val_char,1,8), yymmdd8.);
hour = input(put(input(substr(val_char, 9,2), 4.),z4.),4.);
min = input(put(input(substr(val_char,11,2), 4.),z4.),4.);
sec = input(put(input(substr(val_char,13,2), 4.),z4.),4.);
format val_date2 datetime20.;
val_date2 = dhms(date,hour,min,sec);
run ;
More than 5 years have passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme