Hello everyone,
I would like to ask the question as below,
and I have searched for the definition of multi array,
but I still cannot relate to this question.
Any help would be highly appreciated.
multi array array multi{1:2, 2} (1,2); do i=1 to 2; do j=1 to 2; Output=multi{i,j};
The question is:
What is the corresponding values of i, j and output?
The answer is 1,1,1
Is there any reason you're not running this and checking it?
Anyways, the answer is wrong, it's 1, 2.
A multi array is row by column, so you've specified 1:2, 2 -> which is 2x2 and 4 entries. You've only initialized the first two values, as 1 and 2.
Here's the code for you to run.
data have; array multi{1:2, 2} (1, 2); do i=1 to 2; do j=1 to 2; Output=multi{i, j}; output; end; end; run; proc print data=have; run;
And here's the documentation reference - it's fairly detailed and thorough in my opinion.
@jc3992 wrote:
Hello everyone,
I would like to ask the question as below,
and I have searched for the definition of multi array,
but I still cannot relate to this question.
Any help would be highly appreciated.
multi array array multi{1:2, 2} (1,2); do i=1 to 2; do j=1 to 2; Output=multi{i,j};The question is:
What is the corresponding values of i, j and output?
The answer is 1,1,1
the code you have provided will not output because you have missing end statements for 2 of your do loops;
Depending on your end statements will have an impact on the output.
Is there any reason you're not running this and checking it?
Anyways, the answer is wrong, it's 1, 2.
A multi array is row by column, so you've specified 1:2, 2 -> which is 2x2 and 4 entries. You've only initialized the first two values, as 1 and 2.
Here's the code for you to run.
data have; array multi{1:2, 2} (1, 2); do i=1 to 2; do j=1 to 2; Output=multi{i, j}; output; end; end; run; proc print data=have; run;
And here's the documentation reference - it's fairly detailed and thorough in my opinion.
@jc3992 wrote:
Hello everyone,
I would like to ask the question as below,
and I have searched for the definition of multi array,
but I still cannot relate to this question.
Any help would be highly appreciated.
multi array array multi{1:2, 2} (1,2); do i=1 to 2; do j=1 to 2; Output=multi{i,j};The question is:
What is the corresponding values of i, j and output?
The answer is 1,1,1
Thank you!
Yes, I have checked that documentation too.
But I do not fully understand what it is doing and I am not sure about the code I can write to run it.
I am confused what that (1,2) meant.
Thank you very much!!
ARRAY array-name {number-of-elements} <$> <length> <array-elements> <(initial-value-list)>;
Whenever you can't understand specific syntax, find the syntax definition in the documentation. It lists the items in the order and you can match them up to figure out what each term means.
@jc3992 wrote:
Thank you!
Yes, I have checked that documentation too.
But I do not fully understand what it is doing and I am not sure about the code I can write to run it.
I am confused what that (1,2) meant.
Thank you very much!!
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.