Hello everyone,
I'm just started learning SAS, and got a simple question about date informat (don't know if it's too simple or too stupid).
Since ANYDTDTEw informat can read any date styles, why does SAS have so many other date informats, like mmddyy, ddmmyy,date, julian...)? is it nevessary to keep them? In my opinion, actually very few people like to use the simple way (ANYDTDTEw), is there any reason for this?
thanks,
If the data is supposed to be in one format when received and does not match the specified format the resulting missing values help identify records with the problem for correction.
Also with two digit years in some formats you don't want anydt guesing. If you have a value like 020104 that you know is supposed to be 4 Jan 2002 the anydt algorithm is going to get Feb 1 2004 or 2 Jan 2004 depending on locale settings. Not that I like data in that format but it occurs.
When you use ANYDTDTE you're allowing SAS to guess for you what the date informat actually is, but if you know what it is, it's better to specify it. This way, any dates that are enterered incorrectly will return a missing value or error.
Also, ANYDTDTE doesn't recognize all date informats.
And finally, ANYDTDTE was introduced in SAS 9, so it hasn't always existed and the other ones are required for backwards compatability.
Here's a paper on it from a few years ago:
http://support.sas.com/resources/papers/proceedings11/117-2011.pdf
If the data is supposed to be in one format when received and does not match the specified format the resulting missing values help identify records with the problem for correction.
Also with two digit years in some formats you don't want anydt guesing. If you have a value like 020104 that you know is supposed to be 4 Jan 2002 the anydt algorithm is going to get Feb 1 2004 or 2 Jan 2004 depending on locale settings. Not that I like data in that format but it occurs.
Further to the comments provided, the ANYDTDTEw informat is very useful when you may have different format layouts in the same column.
The way in which SAS determines the layout ie/ Month Day Year or Day Month Year etc is based on your SAS system locale and datestyle options. It is mentioned in the paper @Reeza references and I spoke about it at our local SAS user group meeting a while ago too - http://www.sascommunity.org/mwiki/images/a/a6/2013-09-26-QUESTTipsAndTechniques-MichelleHomes.pdf
I found that not many people know about this very useful informat as they may copy/paste existing code. It can be extremely useful for free-format date fields where the date layout can change in the source file.
Kind Regards,
Michelle
thanks, very helpful.
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.