Skip to content

Feature request: sas_numeric_to_date() function for SAS files #475

@billdenney

Description

@billdenney

Feature requests

As an analogy to excel_numeric_to_date(), I think that a sas_numeric_to_date() function could help. SAS formats its dates in a vaguely similar way, but SAS dates and date/times start from 1960-01-01 and times are seconds since midnight on the current day (https://v8doc.sas.com/sashtml/lrcon/zenid-63.htm).

I think that the function would be relatively simple with the following arguments:

  • date_num The date number
  • datetime_num the date/time number
  • time_num The time number
  • tz The time zone

It would check the input date_num and datetime_num to confirm that it is likely the correct type. The ranges are very different, so it seems like it should be okay (the date 3000-01-01 would only be January 5, 1960 if it were accidentally given in the wrong format). Another option would be to have a single date_num argument which would also accept date/time values. And, perhaps the best would be to give both as options and have a guess_from_range argument which would guess if it were a date_num or a datetime_num.

If the input were a date, then a Date object would be the output. If the input were a date and a time or a date/time, then a POSIXct object would be the output. If the input were a time, then an hms object would be the output.

What do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions