4/15/2021 0 Comments How To Read Hostess Dates
I should have mentioned that SAS dates are a HUGE topic at SAS conferences In addition to your presentation, there are dozens of paper by SAS users such as Art Carpenter.If you obtain data from web sites, social media, or other unstandardized data sources, you might not know the form of dates in the data.
For example, the US Independence Day might be represented as 04JUL1776, 07041776, Jul 4, 1776, or July 4, 1776. Fortunately, the ANYDTDTE informat makes it easy read dates like these into SAS. The ANYDTDTE w. informat is a flexible alternative to older informats such as DATE w., MMDDYY w., and YYMMDD w. If your dates are in a specific form, the older informats work great and serve to document that all dates must be in that standard form. As you can see, the ANYDTDTE informat reads six different strings, but converts all of them to the SAS date value that corresponds to 04JUL1776. The string 07041776 can be interpreted as April 7, 1776 or July 4, 1776, depending upon the local convention. Europeans tend to interpret the string as DDMMYYYY whereas the US convention is to use MMDDYYYY. The answer is that the informat looks at the DATESTYLE SAS option. By default, the DATESTYLE option uses the LOCALE system option to guess which style to use. You can use PROC OPTIONS to see the value of these options, which are printed to the SAS log. For my system, the DATESTYLE option is set to MDY, which means that the string 07041776 will be interpreted MMDDYYYY. If you need to read dates that obey a different convention, you can use the global OPTIONS statement to set the DATESTYLE option. There are two other SAS infomats that are similar to the ANYDTDTE informat. Heres a tip to help you remember these seemingly cryptic names. The first part of the name is ANYDT, which means that the input string can be ANY datetime (DT) value. The end of the name refers to the numerical value that is produced by the informat. The resulting value can be a date (DTE), a datetime (DTM), or a time (TME) value. Thus the three informats all have the mnemonic form ANYDTXXX where the XXX suffix refers to the value that is produced. His areas of expertise include computational statistics, simulation, statistical graphics, and modern methods in statistical data analysis. Rick is author of the books Statistical Programming with SASIML Software and Simulating Data with SAS. I knew there would have to be an option to set the style or locale and in finding the datestyle and locale options we set them to DMY and ENAU and he was a happy chappy. Spoke about this tip and other tips at our local SAS user group meeting later that year. If things dont work the way you expect, look for an option or another technique.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |