11-28-2013 08:25 AM
"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.
11-28-2013 09:57 AM
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: http://support.sas.com/documentation/onlinedoc/stat/ex_code/121/modstyex.html
Like data_null_;,to be safe I wouldn't use it.
11-28-2013 12:23 PM
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.
11-29-2013 02:50 AM
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!