BookmarkSubscribeRSS Feed

When using SET datasetname POINT= idnumber   the user will create an infinite loop, unless there is a STOP; statement that is executed. It is easy to forget this, or "hide it in some logics. 
    Of course an experienced SAS user NEVER markes this mistake - until the other day....

Suggestion: Try to implement a check that there is a STOP statement, in the SAS Compiler.
/ Br Anders Sköllermo

10 Comments
Quentin
Super User

I upvoted, but I think this would think lack of a STOP statement would need to be configurable as an error / warning / nowarning, probably with the default being the current nowarning. There are many ways to end a DATA step.  If you have a DATA step with multiple SET statements, you might have one that uses the POINT= option and another that does not.  That step will complete without a STOP statement. 

 

Or a silly step that stops due to looping like:

 

1    data foo ;
2      if _n_ <= 3 then set sashelp.class point=_n_ ;
3    run ;

NOTE: DATA STEP stopped due to looping.
NOTE: The data set WORK.FOO has 4 observations and 5 variables.

(I would actually want to be able to make that "stopped due to looping" note into an error message.)

 

AndersS
Lapis Lazuli | Level 10
Hi! YES you a quite correct.
yabwon
Onyx | Level 15

Agree with @Quentin. Option sounds like a good idea.

 

Bart

 

P.S. I do such mistake at least twice a year (since 2009).

Tom
Super User
Super User

Isn't that what it is already doing with the note you got?

 

The warning would only be wanted there is not some other SET/MERGE/UPDATE statement or INFILE statement that could read past its input and stop the data step in the normal way.

 

Say you wanted to use POINT to attached data from selected observations of a larger dataset.

data want;
  set small ;
  p=pointer;
  set big point=p;
run;

But even then you could still create a step that might get into an infinite loop.  Not sure it is possible to detect every such possibility.

 

 

Quentin
Super User

Yes, the log note I showed is definitely wanted.  I think @AndersS  just wants to catch the simple case where forgetting stop causes an infinite loop.

 

data _null_ ;
  p=3 ;
  set sashelp.class point=p;
run ;

I could imagine a system option PointNoStop=NoWarn|Warn|Error,  similar to MergeNoBy=NoWarn|Warn|Error (which I love!).

 

It could be a simple check if the step had a point option but not STOP statement.  If someone  wanted to use it, they could set it to Error by default.  Then if they were intentionally writing a step that used point without having a STOP they could do it like:

 


options PointNoBy=NoWarn; data want; set small ; p=pointer; set big point=p; run; options PointNoBy=Error;

That's how I use MERGENOBY.  I have it set to ERROR by default. Then if I intentionally want to do a smush (1-1 merge with no by), I set MERGNOBY=NOWARN before the merge, and MERGENOBY=ERROR after.  It's an extra way to say "Yes, I really intended no BY statement in this merge."

 

Personally, I don't use point= enough for this option to be super useful to me, but as an advocate for empowering SAS users to get more error messages when they want, I can see some value.

AndersS
Lapis Lazuli | Level 10

Hi! I like the answer from Quentin. I think  the default should be to some kind of warning. 
At present:  No warning, no error. You just wonder what the computer is doing.

"AI-remark:  Probably the computer is wondering what YOU are doing... ".

 

Another solution is to present more and better info to the user, about the tasks that is running.

/Br AndersS

 

AndersS
Lapis Lazuli | Level 10
Hi! There is no note. None at all. My suggestion is basically - introduce
some kind of message to the user, so the user can CANCEL the running task in
time.

/Br Anders
AndersS
Lapis Lazuli | Level 10
Hi! Many thanks for this Very good remark. There is always plus and minus
with Note, Warnings and Errors.

Too many will spoil everything. /Br AndersS
sean_mealin
SAS Employee
Status changed to: Suggestion Under Review

Thanks for the suggestion. This is something that the dev team needs to evaluate, but it may be a while before we can get to it.

AndersS
Lapis Lazuli | Level 10

Hi Sean_Mealin! I think that some kind of:  warning, option, more info - would be VERY useful. But I do not know the details.

 

Note that the other day I got the Data-step into an infinite loop  - without SET, MERGE, POINT=... !!    UGH!!Ä??

That is a pitty. It takes resources from the computer. AND I was rather upset.
(SAS ODA session terminated because of too much use of storage).

 

Still I am VERY gratefull that I am allowed to use SAS ODA.

/Br AndersS    - "Both my Age and my IQ are 76+"