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

How to to read missing values in SPSS files? After reading misssing = 0 ;/ #48

Closed
programistawpf opened this issue Apr 17, 2019 · 2 comments

Comments

@programistawpf
Copy link

programistawpf commented Apr 17, 2019

only 12 values is not missing but I cant to read missings . How to to read missing values? In this sample misssings are at positions 9:11 of this array.

julia> danes=read_sav(savy[j]);
julia> danes.data[1]
1020-element DataValues.DataValueArray{Float64,1}:
 DataValue{Float64}(1.0)
 DataValue{Float64}(1.0)
 DataValue{Float64}(1.0)
 DataValue{Float64}(1.0)
 DataValue{Float64}(12.0)
 DataValue{Float64}(2.0)
 DataValue{Float64}(2.0)
 DataValue{Float64}(2.0)
 DataValue{Float64}()
 DataValue{Float64}()
 DataValue{Float64}()
 ...


julia> danes.data[1].values
1020-element Array{Float64,1}:
  1.0
  1.0
  1.0
  1.0
 12.0
  2.0
  2.0
  2.0
  0.0
  5.0e-324
  0.0
  ...

This data in SPSS file is like this:

1020-element
1.0
1.0
1.0
1.0
12.0
2.0
2.0
2.0
missing
missing
missing
...

Paul

@programistawpf programistawpf changed the title misssing = 0 ? How to to read missing values in SPSS files? misssing = 0 ? Apr 17, 2019
@programistawpf programistawpf changed the title How to to read missing values in SPSS files? misssing = 0 ? How to to read missing values in SPSS files? After reading misssing = 0 ;/ Apr 17, 2019
@davidanthoff
Copy link
Member

danes.data[1] returns a DataValueArray. You shouldn't directly access its values field, that is an implementation detail. Instead, access individual elements like danes.data[1][1]. That will return a DataValue, and then you can test whether it is a missing value or not with the isna function.

But, broadly speaking, you should really be using StatFiles.jl for this scenario.

@programistawpf
Copy link
Author

Big Thanks,
StatFiles.jl using DataFrames and array is to big for me
Do You meand isnan? isna not egzestist in my Julia 0.7. and 1.03

julia> danes.data[1][10]
DataValue{Float64}()
julia> danes.data[1][10]
DataValue{Float64}()
julia> isnan(danes.data[1][10])
false
julia> isna(danes.data[1][10])
ERROR: UndefVarError: isna not defined
Stacktrace:
 [1] top-level scope at none:0
julia> ismissing(danes.data[1][10])
false
julia> isempty(danes.data[1][10])
ERROR: MethodError: no method matching iterate(::DataValues.DataValue{Float64})

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

2 participants