Using data-mapped variables in analysis specifications
The main use for data-mapped variables in analysis specifications is to define conditions for tables and table elements. You can do this in the following ways:
Define conditions using the c= keyword
You can test the values of data-mapped variables as part of logical expressions. This means that you can use the standard c= keyword on tab and l statements to create analysis conditions. For example, you might create the following axis:
l q23
ttlQ.23 Which of the following have you bought in the last week?
n10Total
n03
n01Fridge; c=q23 $Fridge$
n01Freezer; c=q23 $Freezer$
n01Microwave oven; c=q23 $Microwave\$
n01Coffee maker; c=q23 $Filter coffee maker$
n01Toaster; c=q23 $Toaster$
n01None of these; c=q23 $None\$
n01Don't know/Not answered; c=-
Write specifications using the var and val statements
Just as col and val statements make it a lot easier to write specifications using standard data variables, the var statement provides the same shortcuts for data-mapped variables. For example, you could write the above axis as follows:
l q23
ttlQ.23 Which of the following have you bought in the last week?
var q23;base=Total;hd;Fridge;Freezer;Microwave oven;
+Coffee maker=$filter coffee\$;Toaster;
+None of these;Don't know/Not answered=rej
By default, the var statement uses the element text as the response text to create the condition required. If this is not correct (as with the Coffee maker element), you can specify the required response text using the = operator.
When analyzing data-mapped variables that contain numerical values, you can use either the var or val statements. For example, the following two statements are equivalent:
val q17;=;base=Total;hd=Number Bought;hd=-------------;
+1;2;3;4;5;6;7;8;9;10 or more;Don't know/Not answered=rej
var q17;=;base=Total;hd=Number Bought;hd=-------------;
+1;2;3;4;5;6;7;8;9;10 or more;Don't know/Not answered=rej
Whether analyzing numerical or categorical data, var has an added advantage over col and val equivalents in that you can combine several variables on one statement. This ability extends the power of the var statement so that it becomes an equivalent to the fld statement too. To combine two or more variables, place a comma-separated list of variables where you would normally specify the single variable. For example, if the variable q25 held information about the first appliance purchased and the variable q26 on the second purchased, you could use the var statement to combine them as follows:
l q25_26
var q25,q26;base=Total;hd=Appliances purchased;hd=---------------
+Fridge;Freezer;Microwave oven;
+Coffee maker=$filter coffee\$;Toaster;
+None of these;Don't know/Not answered=rej
Often, lists of items such as these are specified in the data using a code number. Therefore, if, instead of the actual names, a numerical code is given to each type of appliance and the codes are assigned to q25 and q26, the above example can be written as:
l q25_26
var q25,q26;base=Total;hd=Appliances purchased;hd=--------------
+Fridge=134;Freezer=135;Microwave oven=102;
+Coffee maker=117;Toaster=203;
+None of these=0;Don't know/Not answered=rej
See also