1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【SAS】yyyymmddhhmmss形式の値のSAS日時値への変換

Last updated at Posted at 2018-03-05
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 ;
1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?