DATA Step, Macro, Functions and more

What is the difference between explicit and implicit array?

Reply
Frequent Contributor
Posts: 86

What is the difference between explicit and implicit array?

According my knowledge :

 

Implicit array : we cannot control it always increment by 1 (do over).

 

Explicit array : we can control it by iteration..

Super User
Super User
Posts: 9,599

Re: What is the difference between explicit and implicit array?

Posted in reply to rajeshalwayswel

There are a few papers out on the subject:

http://support.sas.com/resources/papers/proceedings10/209-2010.pdf

http://www2.sas.com/proceedings/sugi30/242-30.pdf

 

These can describe better than a post.  Also the SAS documentation is there to provide instructions.

Super User
Posts: 23,663

Re: What is the difference between explicit and implicit array?

Posted in reply to rajeshalwayswel

DO OVER is deprecated like 20 years ago. People still use it, but you should use the explicit version instead. 

 

SAS maintains its functionality for backwards compatibility but there's a reason you didn't find it in the documentation.

Super User
Super User
Posts: 8,069

Re: What is the difference between explicit and implicit array?

[ Edited ]
Posted in reply to rajeshalwayswel

Not quite right. With EXPLICIT array reference you include the array index value when you reference the array.  So you would use references like 

do i=1 to dim(x);
  x(i) = x(i) *100;
end;

With IMPLICIT array reference the index value is always in the same variable (default variable is _I_) and if you want to change which element in the array your reference means you change the value of that specific variable.  So you do not add anything in the statement that references the variable.

do _i_=1 to 5 ;
  x = x * 100;
end;

or 

do over x ;
  x = x *100;
end;

Not sure why SAS has dropped the DO OVER from the manuals. Personally I feel it is much clearer when you want to apply the same operation to every element in the array.  Especially when the index has no meaning of its own, for instance if the elements in the list are not ordered in any meaningful way. 

 

Perhaps they feel it is too hard for the compiler to tell which references are array references if you use implicit array references?  Or feel it is too confusing for programmers.

 

The main thing to know is that for each array you have to stick with just one method of referencing it.  You can't use implicit in one statement and explicit in another statement.

Ask a Question
Discussion stats
  • 3 replies
  • 264 views
  • 2 likes
  • 4 in conversation