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

hello - i have been given a dataset called "char_dates" with a variable called "date_added" formatted as $CHAR20. and would like it converted to datetime.

examples of date_added entries:  

3/21/2019 17:05 EDT

3/7/2019 18:10 EST

 

I have attempted the conversion with the following, but have been unsuccessful:

 

data num_dates;

set char_dates;

new_date = input(date_added, anydtdtm19.);

format new_date datetime19.;

run;

 

Any advice?

Mike

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

Get rid of the alphabetic characters EDT or EST

new_date = input(compress(date_added,,'a'), anydtdtm19.);
--
Paige Miller

View solution in original post

4 REPLIES 4
PaigeMiller
Diamond | Level 26

Unsuccessful? Please explain. What happens that is unsuccessful? Why do you think the result is unsuccessful? Are there error messages (if so, please show us)?

--
Paige Miller
Orange4
Calcite | Level 5

my apologies - no error is created; rather the output is missing / null

PaigeMiller
Diamond | Level 26

Get rid of the alphabetic characters EDT or EST

new_date = input(compress(date_added,,'a'), anydtdtm19.);
--
Paige Miller
Orange4
Calcite | Level 5

brilliant - thanks so much!

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

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!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 982 views
  • 0 likes
  • 2 in conversation