FOCUS AREAS


Contents | SAS Program | PDF

The %MktAllo Macro

Introduction

The %MktAllo autocall macro manipulates data for an allocation choice experiment, which is a choice experiment where multiple choices are made. The %MktAllo macro takes as input a data set that has one row for each alternative of each choice set. The input data set must include a variable that indicates the number of times each alternative is chosen. The %MktAllo macro produces an output data set that includes a variable that indicates the number of times each alternative is chosen and the number of times it is not chosen.

%MktAllo Macro Syntax

%MktAllo(FREQ=variable, NALTS=n, VARS=variable-list <, optional arguments>)

Required Arguments

FREQ=variable

specifies the frequency variable, which contains the number of times this alternative was chosen.

NALTS=n

specifies the number of alternatives (including the constant alternative, if appropriate).

VARS=variable-list

specifies the variables in the data set that are used in the analysis, but not the FREQ= variable.

Optional Arguments

DATA=SAS-data-set

specifies the input SAS data set. By default, the macro uses the last data set that is created.

OUT=SAS-data-set

specifies the output SAS data set. The default data set name is Allocs.

Help Option

You can specify either of the following to display the option names and simple examples of the macro syntax:

%mktallo(help)
%mktallo(?)

%MktAllo Macro Notes

This macro specifies options nonotes throughout most of its execution. If you want to see all the notes, submit the following statement before running the macro:

%let mktopts = notes;

To see the macro version, submit the following statement before running the macro:

%let mktopts = version;

Example

In a hypothetical allocation experiment, physicians are asked to specify which of 10 drugs they would prescribe to their next 10 patients. In this study, 10 drugs, Drug 1 through Drug 10, are each available at three different prices, $50, $75, and $100. The following SAS statements read the data into the data set Drugs. The data set contains the following variables: Set, Brand, Count, and Price. Set indexes the choice sets, Brand records the brand name of the alternative drugs, Count records the number of times each drug is chosen, and Price records the price of each drug. There are 27 choice sets. The constant alternative is indicated by a missing value for Brand.

data Drugs;
   input Set Brand $ 4-12 Count Price;
   datalines;
1           0   .
1  Brand 1  103 50
1  Brand 2  58  75
1  Brand 3  318 50
1  Brand 4  99  75
1  Brand 5  54  100
1  Brand 6  83  100
1  Brand 7  71  100
1  Brand 8  58  100
1  Brand 9  100 50
1  Brand 10 56  100

   ... more lines ...

27 Brand 1  68  100
27 Brand 2  101 100
27 Brand 3  352 75
27 Brand 4  58  50
27 Brand 5  82  75
27 Brand 6  60  100
27 Brand 7  47  100
27 Brand 8  73  100
27 Brand 9  94  50
27 Brand 10 65  75
;

The following statement invokes the %MktAllo macro:

%mktallo(data=drugs, out=allocation, nalts=11,
         vars=set brand price, freq=Count)

The DATA= argument specifies Drugs as the input data set, the OUT= argument specifies that the output data set be named Allocation, the NALTS= argument specifies that there are 11 alternatives in each choice set, the VARS= argument names the variables in the data set that are used in the analysis (excluding the FREQ= variable), and the FREQ= argument specifies that Count contain the the number of times each alternative is chosen for each choice set.

The following statements print the first 22 observations of the output data set Allocation:

proc print data=allocation(obs=22);
   var set brand price count c;
run;

Figure 1 shows that there are two observations per alternative for each choice set in the output data set and a new variable C that indexes the two observations. In the observations where C equals 1, the FREQ= variable (Count) contains the number of times the alternative is chosen. In the observations where C equals 2, the FREQ= variable contains the number of times the alternative is not chosen.

Figure 1: Allocated Data Set

Obs Set Brand Price Count c
1 1   . 0 1
2 1   . 1000 2
3 1 Brand 1 50 103 1
4 1 Brand 1 50 897 2
5 1 Brand 10 100 56 1
6 1 Brand 10 100 944 2
7 1 Brand 2 75 58 1
8 1 Brand 2 75 942 2
9 1 Brand 3 50 318 1
10 1 Brand 3 50 682 2
11 1 Brand 4 75 99 1
12 1 Brand 4 75 901 2
13 1 Brand 5 100 54 1
14 1 Brand 5 100 946 2
15 1 Brand 6 100 83 1
16 1 Brand 6 100 917 2
17 1 Brand 7 100 71 1
18 1 Brand 7 100 929 2
19 1 Brand 8 100 58 1
20 1 Brand 8 100 942 2
21 1 Brand 9 50 100 1
22 1 Brand 9 50 900 2