Calling Functions in the R Language


Date, Time, and Datetime Values

R supports date and time data differently than does SAS software. In SAS software, variables that represent dates or times are assigned a format such as DATE9. or TIME5. In R, classes are used to represent dates and times.

When a variable in a SAS data set is transferred to R software, the variable’s format is examined and the following occurs:

  • If the format is in the family of date formats (for example, DATEw.d), the variable in R is assigned the "Date" class.

  • If the format is in the family of datetime formats (for example, DATETIMEw.d) or time formats (for example, TIMEw.d), the variable in R is assigned the "POSIXct" and "POSIXt" classes.

  • In all other cases, the variable in R is assigned the "numeric" class.

When a variable in an R data frame is transferred to SAS software, the variable’s class is examined and the following occurs:

  • If the variable’s class is "Date," the corresponding SAS variable is assigned the DATE9. format.

  • If the variable’s class is "POSIXt," the corresponding SAS variable is assigned the DATETIME19. format.

  • In all other cases, the SAS variable is not assigned a format.