@harcluna
You normally get answers quicker and better suited to your problem if you provide representative sample data via a working SAS data step covering all your cases. We can't know what you're actually dealing with.
Dates in SAS
SAS stores dates as the count of days since 1/1/1960 as a simple number in a numeric variable. You then can apply a SAS Date FORMAT to make this number human readable. Such a format is only for display and it doesn't change the internally stored value (the count of days). In your case the format is worddate.
You use SAS date INFORMATS to instruct SAS how to interprete a string representing a date so SAS can convert this string into a SAS Date value (the count of days).
The problem you're dealing with is that your date strings are so varying using multiple patterns for representing a date. There isn't a one fits all SAS INFORMAT to deal with all these patterns. You need to write code which can try multiple Informats and then stops once one of these Informats has been successful (=text string converted resulting in a non-missing numeric value).
You can find the list of available SAS Date Informats here:
http://support.sas.com/documentation/cdl/en/leforinforref/64790/HTML/default/viewer.htm#n0verk17pchh4vn1akrrv0b5w3r0.htm
What complicates things: There is no Informat for a date string pattern of yyyydmon like 20121Jul
For such cases you need either to implement your own informat or you need to add some additional logic in your code which transforms the string to something for which you've got an informat (i.e. recombine the string using substring() functions and then concatenate the substrings the way you need them).
The code below uses a combination of above. It creates a custom informat using a Regular Expression which recombines the input string and then applies the DATE9. informat to this recombined string. That's only one way of doing things and if you're not familiar with Regular Expressions then you probably want to implement such logic as an additional block in your data step.
Here you go:
proc format;
/* convert date string to a pattern for which there is a SAS Date Informat */
invalue yyyyddmon (default=9)
's/^\s*(\d{4})(\d{1,2}[a-z]{3})\s*$/\2\1/i' (regexpe) = [date9.]
other=_same_;
run;
options datestyle=mdy;
data sample;
input inDateString :$20.;
format outSASDateValue worddate.;
if not missing(inDateString) then
do;;
/* try: read the string and convert to SAS Date value using different INformats */
do tryInFMT='anydtdte.','mmddyy10.','yyyyddmon.';
outSASDateValue=inputn(inDateString,tryInFMT);
/* check: stop trying if conversion successful */
if not missing(outSASDateValue) then leave;
end;
end;
datalines;
3july1965
20121Jul
201201Jul
07112007
07/11/2007
;
proc print;
run;
... View more