@@ -19,7 +19,7 @@ using Base.Test
19
19
end
20
20
end
21
21
22
- @testset " manual " begin
22
+ @testset " incremental read " begin
23
23
fname = " test1.sas7bdat" # 10 rows
24
24
handler = SASLib. open (fname)
25
25
@test handler. config. filename == fname
@@ -31,7 +31,7 @@ using Base.Test
31
31
@test result[:nrows ] == 3
32
32
end
33
33
34
- @testset " numeric " begin
34
+ @testset " various data types " begin
35
35
result = readsas (" test1.sas7bdat" )
36
36
df = result[:data ]
37
37
@test sum (df[:Column1 ][1 : 5 ]) == 2.066
@@ -40,7 +40,7 @@ using Base.Test
40
40
@test df[:Column4 ][1 : 3 ] == [Date (" 1965-12-10" ), Date (" 1977-03-07" ), Date (" 1983-08-15" )]
41
41
end
42
42
43
- @testset " datetime" begin
43
+ @testset " datetime with missing values " begin
44
44
result = readsas (" datetime.sas7bdat" )
45
45
df = result[:data ]
46
46
@test (result[:nrows ], result[:ncols ]) == (5 , 4 )
@@ -50,6 +50,28 @@ using Base.Test
50
50
@test count (ismissing, result[:data ][:dt ]) == 3
51
51
end
52
52
53
+ @testset " include/exclude columns" begin
54
+ result = readsas (" productsales.sas7bdat" , include_columns= [:MONTH , :YEAR ])
55
+ @test result[:ncols ] == 2
56
+ @test sort (result[:column_symbols ]) == sort ([:MONTH , :YEAR ])
57
+
58
+ result = readsas (" productsales.sas7bdat" , include_columns= [1 , 2 , 7 ])
59
+ @test result[:ncols ] == 3
60
+ @test sort (result[:column_symbols ]) == sort ([:ACTUAL , :PREDICT , :PRODUCT ])
61
+
62
+ result = readsas (" productsales.sas7bdat" , exclude_columns= [:DIVISION ])
63
+ @test result[:ncols ] == 9
64
+ @test ! (:DIVISION in result[:column_symbols ])
65
+
66
+ result = readsas (" productsales.sas7bdat" , exclude_columns= collect (2 : 10 ))
67
+ @test result[:ncols ] == 1
68
+ @test sort (result[:column_symbols ]) == sort ([:ACTUAL ])
69
+
70
+ # error handling
71
+ @test_throws SASLib. ConfigError readsas (" productsales.sas7bdat" ,
72
+ include_columns= [1 ], exclude_columns= [1 ])
73
+ end
74
+
53
75
@testset " misc" begin
54
76
result = readsas (" productsales.sas7bdat" )
55
77
df = result[:data ]
0 commit comments