I never have an easy time converting dates in this language.
I imported a set of dates from an excel sheet that follow the form "2016/02/23 18:24:00"
Once loaded they have the following properties:
Type: Char
Len: 27
I would like to convert them to a workable SAS date format (date9.). I tried a number of approaches without success - online resources aren't super helpful when it comes to SAS date formats.
Please advise
data example;
datetime_char="2016/02/23 18:24:00";
datetime_want=input(datetime_char,anydtdtm.);
date_want=datepart(datetime_want);
format datetime_want datetime18. date_want date9.;
run;
@Ross12345 wrote:
I never have an easy time converting dates in this language.
I imported a set of dates from an excel sheet that follow the form "2016/02/23 18:24:00"
Once loaded they have the following properties:
Type: Char
Len: 27
I would like to convert them to a workable SAS date format (date9.). I tried a number of approaches without success - online resources aren't super helpful when it comes to SAS date formats.
Please advise
Part of the issue is that "dates" in Excel sometimes aren't. I've had to process files where half the dates were entered as character values. So even Excel couldn't treat them as dates, or more properly, datetime values.
It might help to share the approaches that did not work and exactly why they didn't.
BTW, this is an "online resource" and we get to answer this question in one form or another at least once a week.
Here's a great, but longer and in depth, reference for dates and times in SAS
https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/...
@Ross12345 wrote:
I never have an easy time converting dates in this language.
I imported a set of dates from an excel sheet that follow the form "2016/02/23 18:24:00"
Once loaded they have the following properties:
Type: Char
Len: 27
I would like to convert them to a workable SAS date format (date9.). I tried a number of approaches without success - online resources aren't super helpful when it comes to SAS date formats.
Please advise
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.