Data editing > Data-mapped variables > Using data-mapped variables
 
Using data-mapped variables
Data-mapped variables can hold both numerical and categorical data. If a data-mapped variable is storing numerical data, it can be used in exactly the same way as any other numerical variable.
For example, you can:
Assign a value to the variable, for example:
my_mapvar=t1+23
Assign the value of the variable to another variable, for example:
x1=my_mapvar
Use the value as part of an arithmetic expression, for example:
t1=t1+my_mapvar-4
Test the value using logical operators (that is, .eq., .ne., .lt., .le., .ge. and .gt.), for example:
r(my_mapvar .ne. 0)$Zero value given$
Use the value as an increment, for example:
n01Total bought;c=my_mapvar.gt.0;inc=my_mapvar
Analyze the value using the val statement, for example:
val my_mapvar;=;base=Total;1;2;3;i;4-5;6+
Analyze the value using the var statement, for example:
var my_var;=;base=Total;1;2;3;i;4-5;6+
For data-mapped variables storing categorical data, its use is similar to using data variables that are storing categorical data. In this case, you can:
Assign the value to another data-mapped variable, for example:
my_mapvar1=my_mapvar2
Test for the presence of a response, for example:
n01Drank Pepsi;c=my_mapvar$Pepsi$
Test for an exact response, for example:
if(my_mapvar=$Coke$) print $Drank only Coke$
Analyze the value using the var statement, for example:
var my_mapvar;base=Total;Coke;Pepsi;Other=$_other$;DK=rej
In addition to normal response code names, packages such as Quancept allow certain special responses in the data. In order to check or set these names, the following special response texts are recognized by Quantum:
Type
Text
Description
Exclusive responses
$_null$
Checks for the null response
 
$_dk$
Checks for the don't know response
 
$_ref$
Checks for the refused response
Non-exclusive responses
$_other$
Checks for the specified other response
Response groups
$_base$
Checks for any response or no response (that is, any situation)
 
$_possible$
Checks if a response was possible
 
$_answered$
Checks for any response present
 
$_normal$
Checks for any normal response (that is, not $_other$)
 
$_precode$
Checks for any precoded response (that is, not $_other$, $_null$, $_dk$ or $_ref$)
 
$_special$
Checks for any special response (that is, $_other$, $_null$, $_dk$ or $_ref$)
Miscellaneous
$_na$
Checks for no present responses
 
$_uniqid$
Represents the response whose unique ID text matches that specified.
When using data-mapped variable arrays, you can refer to the array element just as you would any other variable array, that is, by specifying the element using the numerical index. However, if the data-mapping file contains names for the array elements (note that using a qdi file which was generated by Quancept will create arrays for variables that are iterated and the elements are named after the iterations), then you can use those names to reference specific array elements. For example, if you had the variable array wrate in the Quantum run that stores the rating given to the widget suppliers Wilsons Wonderful Widgets and Just Widgets, you could refer to the rating for each supplier as:
wrate(1)
wrate(2)
or:
wrate($wilsons wonderful widgets$)
wrate($just widgets$)
Also, if the array elements have unique IDs associated with them, then these too may be used to refer to the elements. As with other uses of unique IDs, the ID text is converted to a response text format by placing it within parentheses and prepending the underscore character. Therefore, using the same example as above, you could write this as:
wrate($_(wilsons)$)
wrate($_(justwids)$)
If you are not using a mapping file, or the data-mapped variable is not represented in the mapping file, then each array element will be created when it is first used.
See also
Data-mapped variables