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
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.