Commit b4fb5cd4 authored by Sigbjørn Revheim's avatar Sigbjørn Revheim

Removing null labels from output of Recode command

parent 3a14ac40
......@@ -11,6 +11,7 @@
[instaparse "1.4.9"]
[cheshire "5.5.0"]
[clj-diff "1.0.0-SNAPSHOT"]
[medley "1.1.0"]
]
:uberjar-name "stata2sdtl-standalone.jar"
:profiles {:uberjar {:aot :all}}
......
......@@ -5,6 +5,7 @@
(:require
[stata2sdtl.utils :refer :all]
[stata2sdtl.functions :refer [function-lookup]]
[medley.core :as m]
)
)
......@@ -42,19 +43,21 @@
(defn transform-recode-rule
[& args]
(if (string? (first args))
{:specialFromValue (first args)
:to (second args)
:label (if (> (count args) 2) (nth args 2))}
;; else
(let [values (filter number? (first args))
ranges (filter map? (first args))]
(cond-> {:to (second args), :label (if (> (count args) 2) (nth args 2))}
(not-empty values) (assoc :fromValue values)
(not-empty ranges) (assoc :fromValueRange ranges)
)
)
)
(m/filter-vals
some?
(if (string? (first args))
{:specialFromValue (first args)
:to (second args)
:label (if (> (count args) 2) (nth args 2))}
;; else
(let [values (filter number? (first args))
ranges (filter map? (first args))]
(cond-> {:to (second args), :label (if (> (count args) 2) (nth args 2))}
(not-empty values) (assoc :fromValue values)
(not-empty ranges) (assoc :fromValueRange ranges)
)
)
))
)
(defn make-seq-comparable [s]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment