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
Get rid of the alphabetic characters EDT or EST
new_date = input(compress(date_added,,'a'), anydtdtm19.);
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)?
my apologies - no error is created; rather the output is missing / null
Get rid of the alphabetic characters EDT or EST
new_date = input(compress(date_added,,'a'), anydtdtm19.);
brilliant - thanks so much!
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.