Chapter Contents |
Previous |
Next |
The TRANSREG Procedure |
title 'Choice Model Coding'; data design; array p[4]; input p1-p4 @@; set = _n_; do brand = 1 to 4; price = p[brand]; output; end; brand = .; price = 1.49; output; /* constant alternative */ keep set brand price; datalines; 1.49 1.99 1.49 1.99 1.99 1.99 2.49 1.49 1.99 1.49 1.99 1.49 1.99 1.49 2.49 1.99 1.49 1.49 1.49 1.49 2.49 1.49 1.99 2.49 1.49 1.49 2.49 2.49 2.49 2.49 1.49 1.49 1.49 2.49 2.49 1.99 2.49 2.49 2.49 1.49 1.99 2.49 1.49 2.49 2.49 1.99 2.49 2.49 2.49 1.49 1.49 1.99 1.49 1.99 1.99 1.49 2.49 1.99 1.99 1.99 1.99 1.99 1.49 2.49 1.99 2.49 1.99 1.99 1.49 2.49 1.99 2.49 ; proc transreg data=design design norestoremissing nozeroconstant; model class(brand / zero=none) identity(price); output out=coded; by set; run; proc print data=coded(firstobs=21 obs=25); var set brand &_trgind; run;
|
For the constant alternative (BRAND = .), the brand coding is a row of zeros due to the NORESTOREMISSING o-option, and PRICE is a constant $1.49 (instead of 0) due to the NOZEROCONSTANT a-option.
The data set was coded by choice set (BY set;). This is a small problem, but with very large problems, it may be necessary to restrict the number of observations that are coded at one time so that the procedure uses less time and memory. Coding by choice set is one option. When coding is performed after the data are merged in, coding by subject and choice set combinations is another option. Alternatively, you can specify DESIGN=n, where n is the number of observations to code at one time. For example, you can specify DESIGN=100 or DESIGN=1000 to process the data set in blocks of 100 or 1000 observations. Specify the NOZEROCONSTANT option to ensure that constant variables within blocks are not zeroed. When you specify DESIGN=n, or perform coding after the data are merged in, specify the dependent variable and any other variables needed for analysis as ID variables.
Chapter Contents |
Previous |
Next |
Top |
Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.