BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
MarcBoh
Obsidian | Level 7

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:Minute:Second: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

 

1 ACCEPTED SOLUTION

Accepted Solutions
MarcBoh
Obsidian | Level 7

Thanks Draycut.

 

I made it though with:

 

 

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

 

View solution in original post

3 REPLIES 3
PeterClemmensen
Tourmaline | Level 20

Something like this?

 

data test;
x = "2018-07-07T08:15:09.0325056-05:00";
y = input(x, B8601DZ35.);
format y datetime26.;
put _all_ ;
run;
MarcBoh
Obsidian | Level 7

Thanks Draycut.

 

I made it though with:

 

 

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

 

ballardw
Super User

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;

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