Skip to content

Reading Stata value labels fails for all value labels prior to an empty value label #219

@NilsEnevoldsen

Description

@NilsEnevoldsen

Reported as tidyverse/haven#551

Variables whose value labels appear on the label list prior to one with an empty value label are not assigned their value labels.

Step 1:

input x y z
0 0 0
end

lab def xlab 0 "Foo"
lab val x xlab

lab def ylab 0 "Bar"
lab val y ylab

lab def ylab 0 "", modify // This is one way to create an "empty" value label. It does *not* create a value label with an empty string for value 0.

lab def zlab 0 "FooBar"
lab val z zlab

label list
save example_input

Step 2: readstat example_input.dta example_output.dta

Actual example_output.dta :

Screen Shot 2020-11-22 at 9 06 35 PM

Expected example_output.dta :

Screen Shot 2020-11-22 at 9 06 49 PM

(Minor detail: the blueness of the 0 indicates the presence of an [empty] value label for variable y; I have no strong opinion on whether this value label should be preserved in the output file.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions