dbosak01 / libr

An R package to create data libraries and data dictionaries.
27 stars 1 forks source link

Libname cannot read empty sas dataset #172

Open tapendersingh opened 1 month ago

tapendersingh commented 1 month ago

Dear developers, I used libname function to read the SAS7BDAT datasets, but somehow it fails due to empty sas datasets and gives following error statement - Error in date_validate(): ! Corrupt Date with unknown type logical. i In file type-date-time.c at line 344. i Install the winch package to get additional debugging info the next time you get this error. i This is an internal error that was detected in the vctrs package. Please report it at https://github.com/r-lib/vctrs/issues with a reprex (https://tidyverse.org/help/) and the full backtrace. Backtrace: x

  1. +-libr::libname(rawdata, datalocation, engine = "sas7bdat")
  2. | -libr:::exec_spec(dat, spcs, nm)
  3. | +-base::[[<-(*tmp*, nm, value = <date>)
  4. | -tibble:::[[<-.tbl_df(*tmp*, nm, value = <date>)
  5. | -tibble:::tbl_subassign(...)
  6. | -tibble:::vectbl_recycle_rhs_rows(...)
  7. | +-base::withCallingHandlers(...)
  8. | -vctrs::vec_recycle(value[[j]], nrow)
  9. | -vctrs (local) <fn>()
    1. | -vctrs::vec_proxy(x = x)
    2. | -vctrs:::date_validate(x)
    3. -rlang:::stop_internal_c_lib(...)
    4. -rlang::abort(message, call = call, .internal = TRUE, .frame = frame)

Currently I am using R version 4.3.1 in my organization.

TIA

dbosak01 commented 1 month ago

Hmm, never encountered this. Can you attach your empty SAS dataset so I can test? I don't have SAS.

MarcovT commented 1 week ago

Hi, I also have this issue.

I was able to recreate the issue by doing 2 things:

  1. Create a numeric variable in an empty data set (attached empty.zip)
  2. Set the SAS format of the numeric column to any DATETIME SAS format, i.e., DATETIME., DATETIME16., DATETIME19., etc. (This step triggers the error below)

SAS Code to make dataset:

data work.empty; id = ''; tmpdt = .; format tmpdt datetime16.; delete; run;

R console:

Error in datetime_validate(): ! CorruptPOSIXctwith unknown type logical. i In file type-date-time.c at line 387. i This is an internal error that was detected in the vctrs package. Please report it at <https://github.com/r-lib/vctrs/issues> with a reprex and the full backtrace. Backtrace: x 1. +-libr::libname(test, "U:/", "sas7bdat") 2. | \-libr:::exec_spec(dat, spcs, nm) 4. | +-base::[[<-(tmp, nm, value =) 5. | \-tibble:::[[<-.tbl_df(tmp, nm, value =) 6. | \-tibble:::tbl_subassign(...) 7. | \-tibble:::vectbl_recycle_rhs_rows(...) 8. | +-base::withCallingHandlers(...) 9. | \-vctrs::vec_recycle(value[[j]], nrow) 10. | \-vctrs (local)() 11. | \-vctrs::vec_proxy(x = x) 12. | \-vctrs:::datetime_validate(x) 13. \-rlang:::stop_internal_c_lib(...) 14. \-rlang::abort(message, call = call, .internal = TRUE, .frame = frame)

dbosak01 commented 1 week ago

Thanks for the sample dataset. Let me investigate.