Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
billdenney opened this issue Mar 7, 2022 · 1 comment · Fixed by #476
Closed

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

billdenney opened this issue Mar 7, 2022 · 1 comment · Fixed by #476

Comments

@billdenney
Copy link
Collaborator

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?

@sfirke
Copy link
Owner

sfirke commented Mar 7, 2022

That sounds good to me overall. Thanks for linking to the SAS spec. What you propose for inputs seems thorough and appropriate, allowing for date, OR time, OR date and time, OR date-time. The guessing sounds reasonable to me, as long as it allows for the option of specifying which it is (i.e., don't guess) - and if you're up for writing the guesser 😁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants