Indexed Variables Examples

 

Following are four examples of typical uses of indexed variables:

 

Example 1A (Variable data): Side-by-side product tests where a respondent is asked the same questions for two or more products

 

In a two-product test, where every respondent sees both products and is asked the same set of questions for both, you might want one set of tables with both products in the banner, rather than having two sets of tables for the same questions, one set for each product.

 

Following are the question numbers, logic positions and indexed variable notation (I#) for the two products:

  

 

Product

Product

 

 

Seen 1st

Seen 2nd

I#

Q1

Q1A

Q1B

I1

Q2

Q2A

Q2B

I2

Q3

Q3A

Q3B

I3

Q4

Q4A

Q4B

I4

Q5

Q5A

Q5B

I5

Q6

Q6A

Q6B

I6

Q7

Q7A

Q7B

I7

Q8

Q8A

Q8B

I8

 

The INDEX statements in the glossary would look like:

 

INDEX {Q1A,Q2A,Q3A,Q4A,Q5A,Q6A,Q7A,Q8A}

INDEX {Q1B,Q2B,Q3B,Q4B,Q5B,Q6B,Q7B,Q8B}

 

It can be helpful to add a comment line to the Glossary above the INDEX statements indicating which I# each column corresponds to.

For example:

 

*            I1     I2     I3     I4     I5     I6     I7     I8         - referred to as I1, I2, I3, I4, etc. in logic

INDEX {Q1A,Q2A,Q3A,Q4A,Q5A,Q6A,Q7A,Q8A}      - referred to as IDX (1) in logic                           

INDEX {Q1B,Q2B,Q3B,Q4B,Q5B,Q6B,Q7B,Q8B}      - referred to as IDX (2) in logic     

 

If Product Seen 1st is a code A and Product Seen 2nd is a code B in Q1, then Product Seen 1st can be identified as: I1 (A) and Product Seen 2nd can be identified as: I1(B).

 

If both Q3's (Q3A and Q3B) are rating scales identified as I3 and the product variable I1 is run by the rating scale variable I3, Product Seen 1st's rating will be pulled out for Product Seen 1st and Product Seen 2nd's rating will be pulled out for Product Seen 2nd.

 

Because the indexed variables stack and align the data, there is no need for derotation.

 

The results would look like:

 

Label

 

 

Product A

Product B

 

 

Logic

I1 (A)

I1 (B)

Excellent

(5)

I3 (5)

 

 

 

(4)

I3 (4)

 

 

 

(3)

I3 (3)

 

 

 

(2)

I3 (2)

 

 

Poor

(1)

I3 (1)

 

 

 

 

For this table, the filter must be I3 (1-5) or IDX (1,2) to permit both levels of I3 into the table.

 

Note: Any table filter must include an IDX or I# variable if any IDX or I# was used in the table.

 

Continuing with the above example, the logic for a Total Products column would be:

 

I1 (A,B)

 

You can combine indexed and non-indexed variables in any order. For example, the logic for Product Seen 1st, Males where Males are a code 1 in the variable GENDER, would be:

 

I1 (A) AND GENDER (1)

 

The GENDER variable would not be indexed, since the answer to the Gender question is not changed from Product Seen 1st to Product Seen 2nd.

 

 

You can use the Repeat feature with INDEX. Repeat lets you apply an INDEX command to multiple columns. Write an R in your statement to invoke Repeat. For example:

 

INDEX {Q1A R6, Q7A, Q8A}

INDEX {Q1B R6, Q7B, Q8B}

 

is another way of writing the above INDEX statements.

 

Example 1B (ASCII data): Side-by-side product tests where a respondent is asked the same questions for two or more products

 

In a two-product test, where every respondent sees both products and is asked the same set of questions for both, you might want one set of tables with both products in the banner, rather than having two sets of tables for the same questions, one set for each product.

 

Following are the question numbers, logic positions and indexed variable notation (I#) for the two products:

  

 

Product

Product

 

 

Seen 1st

Seen 2nd

I#

Q1

1/17

1/27

I1

Q2

1/18

1/28

I2

Q3

1/19

1/29

I3

Q4

1/20

1/30

I4

Q5

1/21

1/31

I5

Q6

1/22

1/32

I6

Q7

1/23:3

1/33:3

I7

Q8

1/26

1/36

I8

 

The INDEX statements in the glossary would look like:

 

INDEX {1/17,1/18,1/19,1/20,1/21,1/22,1/23:3,1/26}

INDEX {1/27,1/28,1/29,1/30,1/31,1/32,1/33:3,1/36}

 

If Product Seen 1st is a code A and Product Seen 2nd is a code B in Q1, then Product Seen 1st can be identified as: I1 (A) and Product Seen 2nd can be identified as: I1(B).

 

If both Q3's (1/19 and 1/29) are rating scales identified as I3 and the product variable I1 is run by the rating scale variable I3, Product Seen 1st's rating will be pulled out for Product Seen 1st and Product Seen 2nd's rating will be pulled out for Product Seen 2nd.

 

Because the indexed variables stack and align the data, there is no need for derotation.

 

The results would look like:

 

Label

 

 

Product A

Product B

 

 

Logic

I1 (A)

I1 (B)

Excellent

(5)

I3 (5)

 

 

 

(4)

I3 (4)

 

 

 

(3)

I3 (3)

 

 

 

(2)

I3 (2)

 

 

Poor

(1)

I3 (1)

 

 

 

 

For this table, the filter must be I3 (1-5) or IDX (1,2) to permit both levels of I3 into the table.

 

Note: Any table filter must include an IDX or I# variable if any IDX or I# was used in the table.

 

Continuing with the above example, the logic for a Total Products column would be:

 

I1 (A,B)

 

You can combine indexed and non-indexed variables in any order. For example, the logic for Product Seen 1st, Males where the Gender variable is in position 1/5 and Males are code 1, would be:

 

I1 (A) AND 1/5 (1)

 

The Gender variable would not be indexed, since the answer to the Gender question is not changed from Product Seen 1st to Product Seen 2nd.

 

You can use the Repeat feature with INDEX. Repeat lets you apply an INDEX command to multiple columns. Write an R in your statement to invoke Repeat. For example:

 

INDEX {1/17 R6, 1/23:3, 1/26}

INDEX {1/27 R6, 1/33:3, 1/36}

 

is another way of writing the above INDEX statements.

 

Example 2: Combination tables where you want to combine a series of similar questions or tables into one table, where the rows are the codes and the columns are the questions, or the rows are the questions and the columns are the codes

 

For example, if you have a series of rating scales, you could have one table where there is a row for each rating scale and where the banner columns are the code values. This one table could be used as a summary instead of having a table for every rating scale question.

 

Following is an example of a series of 5-point rating scales to be shown on one table:

 

Q11

Q12

Q13

Q14

Q15

Q16

Q17

Q18

Q19

Q20

 

 

The INDEX statements in the glossary would look like:

 

INDEX {Q11}

INDEX {Q12}

INDEX {Q13}

INDEX {Q14}

INDEX {Q15}

INDEX {Q16}

INDEX {Q17}

INDEX {Q18}

INDEX {Q19}

INDEX {Q20}

 

The filter for the table must be IDX (1-10) to allow all the rating scales into the questions.

 

The banner and table logic would look like:

 

 

 

(5)

(4)

(3)

(2)

(1)

Mean

Label

Logic

I1 (5)

I1 (4)

I1 (3)

I1 (2)

I1 (1)

I1 (1-5)

Total

IDX (1-10)

 

 

 

 

 

 

Q11

IDX (1)

 

 

 

 

 

 

Q12

IDX (2)

 

 

 

 

 

 

Q13

IDX (3)

 

 

 

 

 

 

Q14

IDX (4)

 

 

 

 

 

 

Q15

IDX (5)

 

 

 

 

 

 

Q16

IDX (6)

 

 

 

 

 

 

Q17

IDX (7)

 

 

 

 

 

 

Q18

IDX (8)

 

 

 

 

 

 

Q19

IDX (9)

 

 

 

 

 

 

Q20

IDX (10)

 

 

 

 

 

 

 

 

The IDX logic for each table row refers to the corresponding questions/variables in that row of the index. For the Total (filter) row, the logic would be (IDX (1-10)), for a total of all the rating scales. The Mean for the Total (filter) row would be a Grand Mean.

 

Indexed variables can be manipulated with the RECODE statement. When indexed variables are used with RECODE, many blocks of glossary statements can be reduced.

 

For example, above where there is one table with a row for each rating scale and code values for banner columns, RECODE could be used to recode all 10 variables at one time:

 

RECODE I1 (1=5,5=1,2=4,4=2)

 

meaning, 'For indexed variable 1, recode the value 1 to 5, the value 5 to 1, the value 2 to 4 and the value 4 to 2'.

 

Example 3: Where a limited amount of variables are used for aligned data and you want to create a variable-specific table.

 

For example, a questionnaire might have a respondent indicate five products and then indicate the number of times each of the five products was purchased. This results in five product variables and five variables representing the number of products purchased.

 

If the data is stored in mention order (for example, 1st mention, 2nd mention, 3rd mention, etc.) and not by product, then the variables are not product-specific. You could only determine the number of times a specific product was purchased using indexed variables (or, by tediously creating specific variables for every possible product mentioned).

 

In the following example, the data includes five variables (Q11A-Q11E) that represent two-digit product codes (up to 99 possible product codes for each variable); a specific code could appear in any one of the five variables. The data includes the responses to two other questions that were asked about the chosen products: volume and price. The data includes five variables for each of these questions (Q12A-Q12E for volume and Q13A-Q13E for price) that correspond to the five possible product codes (Q11A-Q11E).

 

Product

Volume

Price

Q11A

Q12A

Q13A

Q11B

Q12B

Q13B

Q11C

Q12C

Q13C

Q11D

Q12D

Q13D

Q11E

Q12E

Q13E

 

The INDEX statements in the glossary would look like:

 

*               I1      I2        I3

INDEX {Q11A,Q12A,Q13A}      - referred to as IDX (1) in logic

INDEX {Q11B,Q12B,Q13B}      - referred to as IDX (2) in logic

INDEX {Q11C,Q12C,Q13C}     - referred to as IDX (3) in logic

INDEX {Q11D,Q12D,Q13D}     - referred to as IDX (4) in logic

INDEX {Q11E,Q12E,Q13E}      - referred to as IDX (5) in logic

 

For a variable-specific table filtered by product code (3), you would set up the rows based on the volume indexed variable I2 and base the table to I1 (3). Then, if product 3 appears on the 3rd row of the INDEX statements (Q11C referenced by IDX (3)) the corresponding volume for that product would appear on that table (Q12C).

 

The only other way to accomplish the same resultswithout using indexed variableswould be to create 99 product-specific volume variables and 99 product-specific price variables.

 

Indexed variables can be manipulated using the ASSIGN statement. When  indexed variables are used with ASSIGN, many blocks of Glossary statements can be reduced.

 

For example, where you determine the number of times a specific product was purchased with indexed variables (above), you can use the ASSIGN statement along with IF to assign a value to an existing location. For example:

 

IF I1 (3) ASSIGN I2 = (97)

 

meaning, 'If indexed variable 1 is a code value of 3, assign a value of 97 to indexed variable 2'.

 

Note: You can use the View|INDEX Statement Map option to display INDEX statements from the Glossary in an easy-to-read grid that can be saved to an Excel file. This can be especially helpful if your INDEX statements are long and/or you are using the Repeat (R) feature.

 

Related topics:

Indexed variables

View|INDEX Statement Map