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!

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 4 replies
  • 584 views
  • 0 likes
  • 2 in conversation