Tables and axes > Introduction to axes > Count-creating elements > n01 statement > Simplifying complex conditions
 
Simplifying complex conditions
You can write conditions of any complexity. For example, you might have a questionnaire that contains two awareness questions, one for awareness of the product and the other for awareness of advertising about it. Awareness of the product is tested using aided and unaided responses, with the first unaided response being coded separately from other unaided responses. Awareness of advertising is also aided and unaided, but there is no distinction between first and subsequent mentions. Here is part of the questionnaire:
Product Awareness Advert Awareness
----------------- ----------------
First Other Aided Unaided Aided
(110) (111) (112) (113) (114)
Sparkle 1 1 1 1 1
Gleam 2 2 2 2 2
Suds 3 3 3 3 3
Washo 4 4 4 4 4
You want to set up statements to create elements showing whether or not respondents were aware of a brand’s existence and whether or not they remembered seeing or hearing any advertising for it, regardless of whether responses were aided or unaided. Statements are as follows:
n01Aware of Sparkle;c=c110'1'.or.c111'1'.or.c112'1'
n01Aware of Gleam;c=c110'2'.or.c111'2'.or.c112'2'
          .
n01Aware of Washo Advertising;c=c113'4'.or.c114'4'
As you can see, the conditions for each element are quite long and require careful typing to collect the appropriate respondents.
A more efficient way of writing such conditions is to merge the codes in columns 110, 111 and 112 into a spare column in the edit as follows:
ed
clear c181
/* c181 = aware of product at all
c181 = or(c110,c111,c112)
    .
end
    .
l q3
n01Aware of Sparkle;c=c181'1'
n01Aware of Gleam;c=c181'2'
    .
This example saves in c181 any codes which are present in at least one of the columns c(110,112): that is, any brand that the respondent is aware of, either spontaneously or after prompting. It then uses this variable to determine which respondents are collected into each element. This example uses the or operator, but this method works equally well for and and xor. For more information about these operators, see Assignment with and, or and xor.
Producing tables for product tests can often be simplified by copying data to different cards according to the order in which the products were tried. In the previous example, in which half the respondents tried A then B while the rest tried B then A, the only way of finding which product the respondent was talking about was to look at the code in column x showing which product was tested first.
This can lead to unnecessarily complex and lengthy specifications. One of the simplest solutions to this is to copy data for each group of respondents to a different card, and to reorganize the order of the data for one set of respondents so that answers about product A always precede answers about product B, regardless of the order in which they were tried. Once this recoding is done, the tabulation of the data becomes straightforward.
Again, here is part of the questionnaire:
Order in which products tried
                  c118
                  ----
A then B            1
B then A            2


Q6 Which product did you prefer for...
                    Prefer | Prefer | | No Real
                  1st Prod.|2nd Prod.|No Pref.| Difference
                  -----------------------------------------
Washing Woolens        1   |    2    |    3   |     4        (127)
Washing Silk           1   |    2    |    3   |     4        (128)
The questionnaire refers to the first and second product tried, but the client wants to know whether respondents preferred Brand A or Brand B for each task. They also want to know whether the item preferred depends upon whether or not it was tried first.
Here is an example of how to write an edit to shift the data and a table specification using the new card.
ed
/*A then B : copy in existing order
if (c118'1') c(401,480)=c(101,180);goto 1
/*B then A : reorganize data as it is copied
c(401,426)=c(101,126)
/*For washing woolens
if (c127'1') c427'2'
if (c127'2') c427'1'
if (c127n'12') c427=c127
/*For washing silk
if (c128'1') c428'2'
if (c128'2') c428'1'
if (c128n'12') c428=c128
c(429,480)=c(129,180)
1 continue
/* rest of edit follows using c(401,480) etc.
end
a;dsp;decp=0;spechar=-*;flush
tab tests order
ttlPreference for Selected Characteristics
l tests
n10Base
n23Washing Woolens
n01Noticed a Difference;c=c427'1/3'
n01 Prefer Product A;c=c427'1'
n01 Prefer Product B;c=c427'2'
n01 No Preference;c=c427'3'
n01Did Not Notice a Difference;c=c427'4'
l order
n10Total
n01Tried A First;c=c418'1'
n01Tried B First;c=c418'2'
The following figure shows what the table might look like.
Preference for Selected Characteristics

                                         Tried A      Tried B
                               Total     First        First
                             
  Base                           330        150          180
                                                       
  Washing Woolens                200         97          103
  Noticed a Difference            61%        30%          57%
                                                      
    Prefer Product A              90         44           46
                                  27%        30%          26%
                                                       
    Prefer Product B              82         36           46
                                  25%        24%          26%
                                                       
    No Preference                 28         17           11
                                   9%        11%           6%
                                                       
    Did Not Notice a             130         53           77
    Difference                    39%        35%          43%
If you had not copied the data to other cards, the definition of someone preferring product A for washing woolens would have been:
n01Prefer Product A;c=(c127'1'.and.c118'1').or.(c127'2'.and.c118'2')
See also
n01 statement