07-13-2016 02:52 PM
Thanks for the response but im getting the following error...
sas_date = input(date, worddate18.);
ERROR 48-59: The informat WORDDATE was not found or could not be loaded
07-13-2016 03:00 PM
Usually there's an informat for the date, but this doesn't have an informat that I could find.
You can create it into a date format that SAS will recognize, I used Date9. format, since it's the most common in SAS.
I use the SUBSTR, SCANx2 function to extract the month, day and year, respectively, and the CATT to concatenate them together.
data have; informat date_char $20.; input date_char $20.; cards; April 1, 2016 December 24, 2016 April 30, 2015 May 18, 2014 November 1, 2012 February 28, 2016 ; run; data want; set have; date_format9 = catt(put(input(scan(date_char, 2), 2.), z2.), substr(date_char, 1, 3), scan(date_char, 3) ); date_num = input(date_format9, date9.); format date_num date9.; run;
07-13-2016 03:07 PM
You guys are right! There's a WORDDATE18 format, but not a WORDDATE18 informat.
Reeza's idea looks good. I might simplify one part:
date_format9 = cats( scan(date_char, 2, ' ,'), substr(date_char, 1, 3), scan(date_char, 3) );
Note that both blanks and commas are being used as delimiters in the first SCAN function.
07-13-2016 05:25 PM
@ballardw Interesting. I tried with ANYDTDTE but didn't specify a width, and that didn't work. I forgot there's a default width
I had done the samething recently with width up to 20. Apparently some of the things anydt reads only work with maximum lengths.
Need further help from the community? Please ask a new question.