Working with Dates in Nonstandard Form

Although SAS software can read dates in almost every conceivable form, there may be times when you have date information for which there is no SAS informat. Suppose you have a month value (a number from 1 to 12) in columns 6-7, a day of the month value (a number from 1 to 31) in columns 13-14, and a four-digit year value in columns 20-23. How can you create a SAS date from these three variables? The MDY (month-day-year) function comes to the rescue. Just enter the three variable names for the month, day, and year as arguments to this function, and it will return a SAS date. Program 4-7 demonstrates how this works.

Program 4-7. Demonstrating the MDY Function to Read Dates in Nonstandard Form
***Sample program ...

Get Cody’s Data Cleaning Techniques Using SAS® Software now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.