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!
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!
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.