I am trying to replace the read.SAS7bdat function with read_sas from the haven package in a number of my programs due to speed. Simply substituting it in works perfectly and reads so much quicker. However, the only hang-up I encounter has to deal with dates and times. For some reason, I can no longer subset by a date selected in an R Shiny date input even though the underlying data looks the same and all other functions work. If anyone knows of a difference between how these two functions read dates that would be greatly appreciated.
Reading Dates/Times from a SAS file: read_sas vs. read.SAS7bdat
543 Views Asked by Nathan At
2
There are 2 best solutions below
0
Nathan
On
There were two components: first I had to change the origin date to 1970 instead of 1960 as I previously was using with read.sas7bdat. I also had previously converted everything to a POSIX date, which worked fine. However, subsetting by an R shiny date input wasn't working with read_sas so I converted the posix using as.date and this resolved it. Not exactly sure why though.
Related Questions in R
- How to make an R Shiny app with big data?
- How do I keep only specific rows based on whether a column has a specific value?
- Likert scale study - ordinal regression model
- Extract a table/matrix from R into Excel with same colors and stle
- How can I solve non-conformable arguments in R netmeta::discomb (Error in B.matrix %*% C.matrix)?
- Can raw means and estimated marginal means be the same ? And when?
- Understanding accumulate function when .dir is set to "backwards"
- Error in if (nrow(peaks) > 0) { : argument is of length zero Calls: CopywriteR ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous> Execution ha
- How to increase quality of mathjax output?
- Convert the time intervals to equal hours and fill in the value column
- How to run an R function getpoints() from IPDfromKM package in an R shiny app which in R pops up a plot that utilizes clicks to capture coordinates?
- Replace NA in list of dfs in certain columns and under certain conditions
- R and text on Cyrillic
- The ts() function in R is returning the correct start and frequency but not end value which is 1 and not 179
- TROUBLING with the "DROP_NA" Function
Related Questions in SHINY
- How to make an R Shiny app with big data?
- How to increase quality of mathjax output?
- How to run an R function getpoints() from IPDfromKM package in an R shiny app which in R pops up a plot that utilizes clicks to capture coordinates?
- Pass column name to lpSolve obj from drop down
- How to dynamically update a selectizeInput?
- How to update an editable data table when a column is edited and use it to perform successive calculations in Shiny
- How do I make sure that the labels of a echarts4r radar chart are completely visible on any screen? Works with bs4Dash::box but not with bslib::card
- How to deploy my shiny application (with multiple files) via Docker
- How to add tabset to table position in this application using Shiny R?
- Run R shiny plotting function with JS in an R Shiny environment
- How to have the pagination display correctly?
- Using Javascript package in R
- How to get new text input after entering a password in a tab?
- Increase y-axis height to fit in geom_text labels according to multiple criteria
- How do you make the pop up appear and print a sentence in the main/side panel?
Related Questions in SAS
- Creating a new flag based on multiple conditions on SAS
- How to sum elements of a specific row?
- why the perl regular expression is not identifying the value
- How does the REPEAT FUNCTION deal with the trailing blanks from the string?
- Stopping SAS adding = to the end of file paths
- How can I collapse repeated missing observations into a single nonmissing observation for the same ID in SAS?
- Issues with Date format in SAS
- SAS Macro Variables
- Unbalanced data in SAS Enterprise Miner
- Cut intervals to add specific dates
- Last.variable not returning expected results
- SQL Filter Rows for Duplicate ID Based on Condition Different Column
- Proc GLM takes forever to load then crashes sas studio
- Having trouble setting x-axis endpoints in proc univariate
- I cannot export parameter estimates for different groups using proc model in SAS
Related Questions in R-HAVEN
- Why isn't df$VARNAME the same as df[,i] when reading data using the R haven package?
- How to assign NA as the value using mutate() and case_when() in R
- How do I collapse levels of two haven-labelled vector variables to use in the polychoric function with fifteen other variables?
- How to Preserve Labels when Importing Data from SPSS and Dealing with Haven Labeled Variables
- Is there a way to convert all haven_labelled data to something that can be used for linear regression/scatter plots/etc?
- import all SAS files in folder and convert labels to column names in R
- pivot_longer() with haven variable labels
- Turning SPSS chr+label variables into labelled factors in R
- How can column labels/descriptions be set in R using values from a dataframe?
- Is there a way to view data in RStudio data viewer and have labelled vectors showing value labels?
- Difficulty converting factors to numeric in R
- What are those red lines with dots in RStudio editor
- recoding SPSS/.sav files in R while retaining metadata
- Label missing values as any other strings
- How to encrypt a SPSS-file using cypher
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Date zero in SAS is 1 Jan 1960, and in R (origin date) it is 1 Jan 1970. That might be the reason for your issue. Bring in dates as character from SAS, and then convert it to numeric in R.