A little announcement. A lot to explore.

Happy learning!

Explore lessons, including SAS & R programs and practice data.

Search lessons

Type at least 3 characters to see matching lessons.

Open SAS ↗Open R ↗
← SASnRConvert Character Strings to Dates

Introduction

  • SDTM dates arrive as ISO 8601 character strings (e.g., "2025-01-15") and must be converted to proper date types before we can do arithmetic.
  • Other source systems may use different formats like "15JAN2025" or "01/15/2025", so we need to handle multiple patterns.
  • SAS uses the INPUT function paired with an informat that matches the character layout.
  • R tidyverse relies on lubridate helper functions named after the component order: ymd(), dmy(), mdy().
  • Base R uses as.Date() with a format string built from strftime tokens like %Y-%m-%d.
  • This lesson parses several common clinical date formats and shows how each language handles bad or unexpected input.

Convert Character Strings to Dates