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

Add the DATETIME13 format to the list of SAS datetime formats #44

Merged
merged 2 commits into from
Nov 18, 2024

Conversation

andreuvall
Copy link
Contributor

This PR adds another date format to the list of SAS datetime formats. It also adds a sample xpt file to test. The xpt file was created by @htbunn using the following SAS instructions.

data mydata;
   dttest=123456;
   format dttest datetime13.;

Copy link

codecov bot commented Nov 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.91%. Comparing base (1a6d601) to head (9191051).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #44      +/-   ##
==========================================
- Coverage   99.91%   99.91%   -0.01%     
==========================================
  Files          11        9       -2     
  Lines        1234     1218      -16     
==========================================
- Hits         1233     1217      -16     
  Misses          1        1              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

@junyuan-chen
Copy link
Owner

@andreuvall Thank you for the PR! I wonder is DATETIME13 the only missing format you would like to add? The change is kind of small for a patch release. Additional format can be added by doing something like below:

using ReadStatTables
push!(ReadStatTables.sas_datetime_formats, "DATETIME13")

@andreuvall
Copy link
Contributor Author

Thank you for the feedback, @junyuan-chen! Yes, I know that users can add formats anytime. It is well documented :) (Yet, I filed this PR because I was asked if I could do so. Getting this format now would help in the short term.)

In the long term, I feel that dropping in formats like this is a never-ending endeavor, especially given that many of these SAS formats accept parameters. Like here, DATETIME13 seems to be an instance of DATETIMEw.d, where "w" can range from 7 to 40 and "d" can range from 0 to 39!

In the source code, I could not see how ReadStatTables.jl distinguishes the different SAS formats. I found this section, where I understand that any SAS format (date, time or datetime) is added with respect to the SAS epoch date. Then, the period length is days for dates, and it is seconds both for times and datetimes. But that seems to be all. I wonder if a more general solution could be implemented, only requiring to know the file extension (for example, sas7bdat, or xpt) and whether the data stored are dates or times/datetimes.

@junyuan-chen
Copy link
Owner

OK. I see. The current way how date/time format for SAS is handled is coarse. There should be a smarter way for these variable parts of DATETIME to be accommodated. But I decide to keep your fix with DATETIME13 for now so that things can move on.

@junyuan-chen junyuan-chen merged commit dcfcb58 into junyuan-chen:main Nov 18, 2024
10 checks passed
@andreuvall
Copy link
Contributor Author

The current way how date/time format for SAS is handled is coarse. There should be a smarter way for these variable parts of DATETIME to be accommodated.

OK, I was under this impression, but I wasn't completely sure. Good to have it confirmed from you. Then, if I think of a simpler way to handle this, I'll make sure to contact you here.

Thank you for accepting the PR, @junyuan-chen!

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 this pull request may close these issues.

2 participants