Skip to content

Add support for infinity values from sas7bdat files #781

@gowerc

Description

@gowerc

Recommendation within SAS is to store infinity and negative infinity as the special missing values .I and .M respectively:
https://documentation.sas.com/doc/en/imlug/15.2/imlug_r_sect019.htm

Currently when using haven::read_sas() everything just gets read in as NA with no distinction

data outlib.test_special_values;
    input
        my_int
        my_float
    ;
    if _N_ = 1 then do;
        my_int = .;         /* Missing */
        my_float = .;       /* Missing */
    end;
    else if _N_ = 2 then do;
        my_int = .I;        /* Infinity */
        my_float = .I;      /* Infinity */
    end;
    else if _N_ = 3 then do;
        my_int = .N;        /* Not a Number */
        my_float = .N;      /* Not a Number */
    end;
    else if _N_ = 4 then do;
        my_int = .M;        /* Minus Infinity */
        my_float = .M;      /* Minus Infinity */
    end;
    datalines;
. .
. .
. .
. .
;
run;
> haven::read_sas("data/test_special_values.sas7bdat")
# A tibble: 4 × 2
  my_int my_float
   <dbl>    <dbl>
1     NA       NA
2     NA       NA
3     NA       NA
4     NA       NA

That being said I wasn't sure if this needed to be raised upstream first with readstat, I wasn't able to see any obvious functions / metadata that would disambiguate between the different missings.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions