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

read_sas() bug with SAS formats #768

Open
dwilson98-kermit opened this issue Dec 11, 2024 · 0 comments
Open

read_sas() bug with SAS formats #768

dwilson98-kermit opened this issue Dec 11, 2024 · 0 comments

Comments

@dwilson98-kermit
Copy link

read_sas() fails to appropriately process SAS formats that include negative values.
For example, if you have a .sas7bdat file with a single numeric variable named x with values -7, 1, and 2 and a SAS format catalog file that defines the format:

proc format;
value testf
-7="Missing"
1="Yes"
2="No"
;
run;

Then the attributes of dataframe$x show a value of -0.625 instead of -7.

``` r
library(haven)
bweights <- read_sas('C:/Test/test.sas7bdat', catalog_file='C:/Test/formats.sas7bcat')
attributes(bweights$x)
#> $format.sas
#> [1] "TESTF"
#> 
#> $class
#> [1] "haven_labelled" "vctrs_vctr"     "double"        
#> 
#> $labels
#> Missing     Yes      No 
#>  -0.625   1.000   2.000
[test.zip](https://github.com/user-attachments/files/18101365/test.zip)
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

No branches or pull requests

1 participant