Here's some simple code that exemplifies an issue I'm having:
data;
array grid (3,3) row1-row3 col1-col3;
run;
Here's the error message I receive:
The specification is (Dimension1, Dimesnion2) with the total number of values being Dimension1 * Dimension 2.
So for 3x3 you have 9 values, not 6 but you've only indicated 6 names.
Here's two examples of code that does work:
data one;
array _grid (2, 3) row1 - row3 col1-col3;
do i=1 to 2;
do j=1 to 3;
_grid(i, j)=i*j;
end;
end;
run;
data two;
array _grid (3, 2) row1 - row3 col1-col3;
do i=1 to 3;
do j=1 to 2;
_grid(i, j)=i*j;
end;
end;
run;
@genemroz wrote:
Here's some simple code that exemplifies an issue I'm having:
data;
array grid (3,3) row1-row3 col1-col3;
run;
Here's the error message I receive:
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;7273 data;74 array grid (3,3) row1-row3 col1-col3;ERROR: Too few variables defined for the dimension(s) specified for the array grid.75 run;What can possibly be wrong?Thanks,Gene
The specification is (Dimension1, Dimesnion2) with the total number of values being Dimension1 * Dimension 2.
So for 3x3 you have 9 values, not 6 but you've only indicated 6 names.
Here's two examples of code that does work:
data one;
array _grid (2, 3) row1 - row3 col1-col3;
do i=1 to 2;
do j=1 to 3;
_grid(i, j)=i*j;
end;
end;
run;
data two;
array _grid (3, 2) row1 - row3 col1-col3;
do i=1 to 3;
do j=1 to 2;
_grid(i, j)=i*j;
end;
end;
run;
@genemroz wrote:
Here's some simple code that exemplifies an issue I'm having:
data;
array grid (3,3) row1-row3 col1-col3;
run;
Here's the error message I receive:
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;7273 data;74 array grid (3,3) row1-row3 col1-col3;ERROR: Too few variables defined for the dimension(s) specified for the array grid.75 run;What can possibly be wrong?Thanks,Gene
Hmm, OK. I mistakenly thought the names were for rows and columns. Now I realize that they are the names of the elements of the array. Thanks for straightening me out.
Gene
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Get started using SAS Studio to write, run and debug your SAS programs.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.