Do Over?

Respected Advisor
Posts: 4,736

Do Over?

Hi all

"Do Over" has been marked as obsolete in a late version of SAS V6 (I believe to remember) and is for sure no more documented under SAS V9. On the other hand I've seen this syntax used in several white papers after 2010 as well as here in this forum in posts by senior people whom I respect a lot and from whom I continuously learn new stuff.

Once "Do Over" had been defined as "obsolete" I've decided to no more use it. But I can also see the beauty of it when it comes to coding.

Being a technical consultant designing and implementing at customer site I'm now really in a conflict if I should start using "Do Over" again or not. I would like to and it seems to me it's getting a revival. On the other hand it's not documented.




Super User
Posts: 5,876

Re: Do Over?

The documentation for 9.4 even say "The form DO OVER is not supported".

So, as a consultant, I shouldn't use this syntax in production jobs.

Data never sleeps
Respected Advisor
Posts: 3,852

Re: Do Over?

I never say never, but I "never" use DO OVER. Smiley Happy  Implicitly subscripted arrays are obsolete and so is DO OVER.

Posts: 8,164

Re: Do Over?

It is no longer mentioned in the documentation on the "do" statement and the only place I could find mention of it no longer being supported is in the SCL documentation.

Interestingly, it is used in the following sugested code for stat12.1:

Like data_null_;,to be safe I wouldn't use it.

Super User
Super User
Posts: 8,089

Re: Do Over?

Personally I find the DO OVER construct extremely useful and it makes the code much clearer.  I normally use it when the index into the array is meaningless.

A simple example is when you want to apply the same operation to all numeric variables, say to convert special missing values.

array _num _numeric_;

do over _num ; if _num=99 then _num=.; end;

There is no special meaning to the fact that the index into the array for variable X is 5 and index for variable Y is 3 and there is no need to process X before Y then what value does having to explicitly reference index variable add to understanding the code? It will just add clutter to code for both the creator and the consumer.

Now if the index does have meaning, say you have 12 variables that represent months of the year, then I would use an index and the index variable would then have a meaning and a name that reflects that meaning.

array totals jan feb mar apr may jun jul aug sep oct nov dec ;

totals(month)=totals(month) + count;

That said if I was creating production code I would probably not use it because of the lack of documentation and SAS's implied lack of support for it continuing to be available in future versions.

Respected Advisor
Posts: 4,736

Re: Do Over?

Thanks to all of you for your helpful answers and sorry for not being able to mark all of them as helpful like they would deserve.

I agree with Tom that the "do over" construct is very useful but must also agree that I shouldn't use it in production jobs. Pity though!

Ask a Question
Discussion stats
  • 5 replies
  • 5 in conversation