Scan Feature

 

Scan lets you test for one or more values across several variables or fields, so it takes the place of OR. As with all OR logic, at least one condition must be true. You write an S in your logic statement to invoke Scan.

 

Example 1:

For example, if the information is in variable Q1A and there are 7 variables that you want to scan, you would write:

 

Q1A S7 (99)

 

to scan starting with variable Q1A, across 7 variables, for value 99. This statement will scan across 7 variables (Q1A, Q1B, Q1C, Q1D, Q1E, Q1F, Q1G) for value 99.

 

Example 2:

For ASCII data, if the information is on record 1, starts in column 5 and there are 7 fields (each with 2 columns) that you want to scan, you would write:

 

1/5:2 S7 (33)

 

to scan record 1, starting in column 5, across 7 fields (each with 2-columns), for value 33. This statement will scan across 7 fields (columns 5-6, 7-8, 9-10, 11-12, 13-14, 15-16 and 17-18) for value 33.

 

Example 3:

You can Scan single columns. For example:

 

1/35 S3 (Y)

 

Example 4:

You can Scan for multiple values. For example:

 

Q10 S3 (98,99)

 

scans starting with variable Q10, across 3 variables (Q10, Q11, Q12) for value 98 or 99

 

or

 

1/35 S3 (6,7)

 

scans record 1, starting in column 35, across 3 columns (35, 36, 37) for value 6 or 7.

 

Using Skip (+) with Scan

 

Example 5:

You can Scan columns or fields that aren't contiguous, but they must be separated by the same number of columns or fields to ‘skip’. You specify the number of columns or fields between each column to be tested, using the + symbol to indicate the number of columns to skip before the next scan. For example:

 

2/15 S3+1 (9)

 

means, ‘scan for the value 9 on record 2, starting in column 15, across 3 columns, skip one between each.’ The columns tested would be 15, 17 and 19 (the one between each would be skipped (16 and 18). The following example scans multi-column fields:

 

1/21:3 S4+2 (23)

 

meaning, scan for the value 23 on record 1, starting in column 21, across 4 fields, skip 2 between (the fields are three columns wide). The fields tested would be the columns 21-23; 26-28, 31-33; and 36-38.

 

For fields or columns being scanned that start on one record and continue to another, you need only specify the first record number.

 

Example 6:

You can use the Skip feature to skip to a different record for data with multiple records per respondent. For example, to scan a location in both the first record and second record for a respondent, you would check the record length of your data file using View|Data File Information. Assuming the length of your longest record is 167 columns, you would then write:

 

IF 1/40 S2+166 (1-7) ASSIGN 15/45 = (1)

 

meaning, “scan record 1, starting in position 40, across two fields, skip 166 columns between.” The fields tested would be the positions 1/40 and 2/40 because there are 167 columns per record. The +166 would skip from position 40 of record 1 to position 40 of record 2.

 

Example 7:

When the Skip option is used with variable labels it refers to columns, not to variable labels. Variables must be the same length. For example, to scan VAR1A and VAR2A:

 

Variable label

Location:Width

Referring to

VAR1A

1/98:2

answer 1, brand 1

VAR1B

1/100:2

answer 1, brand 2

VAR2A

1/102:2

answer 2, brand 1

VAR2B

1/104:2

answer 2, brand 2

 

You would write:

 

  VAR1A S2+2 (1)

 

meaning, ‘scan the variable VAR1A across 2 variables, skip 2 columns between (the variables are 2-columns wide). The variables tested would be in columns 98-99 and 102-103.’

Related topics:

Logic