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!
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.