Skip to content

read_dta: import value labels for labeled negative values #367

Closed

Description

Example:

tmp <- tempdir()
x1 <- labelled(
  sample(-1:5), 
  c(Good = -1, Bad = 5)
)
df <- tibble::data_frame(x1, z = 1:7)
as_factor(df)
write_dta(df, paste0(tmp,"/df.dta"),version=14)
df1 <- read_dta(paste0(tmp,"/df.dta"))
as_factor(df1)

Here the result of as_factor(df) contains a row Good 7, while the corresponding row of as_factor(df1) is -1 7.00.

The produced Stata file is correct:

. label list x1
x1:
          -1 Good
           5 Bad
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behaviorreadstat

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions