In this article
Studio simplifies the process of defining recoded variables, enabling the reuse of definitions across variables and derived grids to reduce coding effort.
CDL - Defining Recoded Derived Variables
Studio enables you to define recoded variables, simplifying usage and minimizing the need for lengthy single-line IIF statements. This also makes it possible for you to define recoding definitions once and reuse them across variables and derived grids.
The first code example shows a "standard" block of code where the recoding is not defined so it has a long IIF statement.
Original:
variable singleChoice #osatRecoded {
table: survey:
value: IIF(score(survey:OSAT.1) >= 8, "1", IIF(score(survey:OSAT.1) >= 4, "2", IIF(score(survey:OSAT.1) >= 1, "3")))
option code {
code: "1"
score: 3
label: "Satisfied"
}
option code {
code: "2"
score: 2
label: "Neutral"
}
option code {
code: "3"
score: 1
label: "Dissatisfied"
}
}However if you use the recoding values code block below to define the recoding,
With Recoding defined:
recoding values #rec3cats {
mapping {
to: "1"
from: "'1'..'3'"
}
mapping {
to: "2"
from: "'4'..'7'"
}
mapping {
to: "3"
from: "'8'..'10'"
}
}then you can use the code block below instead of the original.
//simplified variable syntax
variable singleChoice #osat2recode {
table: survey:
value: recode(survey:OSAT.1, @rec3cats)
option code {
code: "3"
score: 3
label: "Satisfied"
}
option code {
code: "2"
score: 2
label: "Neutral"
}
option code {
code: "1"
score: 1
label: "Dissatisfied"
}
}And you can use the @rec3cats value anywhere you wish to use the recoding.