DATA Step, Macro, Functions and more

SAS B8601DZ35. Format to Date

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 13
Accepted Solution

SAS B8601DZ35. Format to Date

Hi All,

 

I just downloaded a file where I have the date with time in the format B8601DZ35.  (variable name date_time)

The problem now is that I cannot really work with it. What I need is the date format as YYMMDD10.  (Year-month-day) and the time as Hour:MinuteSmiley Frustratedecond:Millisecond

 

The function year=year(date_time) etc but does not work.

I also tried :

 

data want; set have;
format date_time datetime26.;
put _all_ ;
run;

 

Also no effect. 

How can I extract the individual values of the variable?

Thanks in advance!

 

Marc

 


Accepted Solutions
Solution
2 weeks ago
Occasional Contributor
Posts: 13

Re: SAS B8601DZ35. Format to Date

Thanks Draycut.

 

I made it though with:

 

 

	 date = datepart(date_time);
 	    format date mmddyy10.;
  	 time = timepart(date_time);  

 

View solution in original post


All Replies
PROC Star
Posts: 1,283

Re: SAS B8601DZ35. Format to Date

Something like this?

 

data test;
x = "2018-07-07T08:15:09.0325056-05:00";
y = input(x, B8601DZ35.);
format y datetime26.;
put _all_ ;
run;
Solution
2 weeks ago
Occasional Contributor
Posts: 13

Re: SAS B8601DZ35. Format to Date

Thanks Draycut.

 

I made it though with:

 

 

	 date = datepart(date_time);
 	    format date mmddyy10.;
  	 time = timepart(date_time);  

 

Super User
Posts: 13,566

Re: SAS B8601DZ35. Format to Date

If you don't actually need the time part for anything consider:

data test;
x = "2018-07-07T08:15:09.0325056-05:00";
y = input(x, yymmdd10.);
format y yymmdd10.;
run;
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 100 views
  • 0 likes
  • 3 in conversation