- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi All - I am trying to build a Discrete Choice Experiment (DCE) questionnaire in SAS. I am trying to build a DCE with four generic attributes at three levels, presented in 18 runs.
In each run, respondents will be presented with two alternatives, plus a constant alternative (declining both alternatives).
I am using the following code, but I am generating the error ERROR: Too few variables defined for the dimension(s) specified for the array x.
title 'Generic Distribution Attributes'; %mktex (3 ** 4, n=18, seed=17); data final (drop=i); set design end=eof; retain f1-f2 1 f3 0; output; if eof then do; array x[18]x1-x4 f1-f3; do i=1 to 18; x[i] = i le 4 or i eq 18; end; output; end; run; proc print data=final(where=(x1 eq x3 and x2 eq x4 or f3)); run;
How can I fix this?
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
array x[18]x1-x4 f1-f3;
Your array statement lists 18 items and you loop over 18 items. But X1-X4 is 4 and F1-F3 is 3, which means you're only providing 7 variables for an array you've declared as size 18. You need 11 more variables.
Without having further information about your input data structure, I'm not sure how to fix this.
FYI - the code blocks are for code, your text should go outside the code blocks for legibility. One of the benefits of a code block is to be able to copy just that and paste it into an editor without changes. If you have it all together it doesn't provide that benefit.
@jws47 wrote:
Hi All - I am trying to build a Discrete Choice Experiment (DCE) questionnaire in SAS. I am trying to build a DCE with four generic attributes at three levels, presented in 18 runs.
In each run, respondents will be presented with two alternatives, plus a constant alternative (declining both alternatives).
I am using the following code, but I am generating the error ERROR: Too few variables defined for the dimension(s) specified for the array x.
title 'Generic Distribution Attributes'; %mktex (3 ** 4, n=18, seed=17); data final (drop=i); set design end=eof; retain f1-f2 1 f3 0; output; if eof then do; array x[18]x1-x4 f1-f3; do i=1 to 18; x[i] = i le 4 or i eq 18; end; output; end; run; proc print data=final(where=(x1 eq x3 and x2 eq x4 or f3)); run;
How can I fix this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
array x[18]x1-x4 f1-f3;
Your array statement lists 18 items and you loop over 18 items. But X1-X4 is 4 and F1-F3 is 3, which means you're only providing 7 variables for an array you've declared as size 18. You need 11 more variables.
Without having further information about your input data structure, I'm not sure how to fix this.
FYI - the code blocks are for code, your text should go outside the code blocks for legibility. One of the benefits of a code block is to be able to copy just that and paste it into an editor without changes. If you have it all together it doesn't provide that benefit.
@jws47 wrote:
Hi All - I am trying to build a Discrete Choice Experiment (DCE) questionnaire in SAS. I am trying to build a DCE with four generic attributes at three levels, presented in 18 runs.
In each run, respondents will be presented with two alternatives, plus a constant alternative (declining both alternatives).
I am using the following code, but I am generating the error ERROR: Too few variables defined for the dimension(s) specified for the array x.
title 'Generic Distribution Attributes'; %mktex (3 ** 4, n=18, seed=17); data final (drop=i); set design end=eof; retain f1-f2 1 f3 0; output; if eof then do; array x[18]x1-x4 f1-f3; do i=1 to 18; x[i] = i le 4 or i eq 18; end; output; end; run; proc print data=final(where=(x1 eq x3 and x2 eq x4 or f3)); run;
How can I fix this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Reeza - Thank you for your response! I changed the magnitude of the array and it worked. Thank you!
Julia
Ps. Thank you for your notes on posting etiquette - very helpful!