On Thu, 21 Jun 2007 14:02:54 +0000, Ian Whitlock <iw1junk@COMCAST.NET>
>Summary: The implied loop of the DATA step is driven by input.
>Robert Bardos <bardos2@ANSYS.CH> considered:
>> data _null_ ;
>> put 'before set iteration' _n_ 2.;
>> do until (1=2);
>> set sashelp.class(obs=3) end=eod;
>> put 'after set iteration' _n_ 2.;
>> run ;
>> I guess what surprises me most is the 'after' message not showing up.
>> Anybody care to explain what exactly happens in the first data step?
>The DO-loop runs "forever" because 1 is not 2 just like 0 is false. So
>what does SAS do when asked to read an observation that it isn't there? It
>stops. Where? On the line requesting the read that cannot be fulfilled.
> data _null_ ;
> put 'before set iteration' _n_ 2.;
> do until (1=2);
> put "top of DO-loop" ;
> set sashelp.class(obs=3) end=eod;
> put "bottom of DO-loop" ;
> put 'after set iteration' _n_ 2.;
> run ;
>would be more enlightening.
>I find it puzzling that one can become an expert SAS programmer without
>knowing when, why, and where a DATA step stops processing. I suppose it
>must be a tribute to the naturalness of the language.
The above is understood, but I could use expert insight on why
adding an end= option to a second set makes it *read* two obs.
instead of one:
624 data _null_;
625 put 'before set1 iteration' _n_ 2.;
626 do until (eod);
627 set sashelp.class end=eod;
629 put 'after set1 iteration' _n_ 2.;
630 set sashelp.shoes; *end=finito;
631 put 'after set2 iteration' _n_ 2.;
before set1 iteration 1
after set1 iteration 1
after set2 iteration 1
before set1 iteration 2
NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: There were 1 observations read from the data set SASHELP.SHOES.
include the second end= and observe that
NOTE: There were 2 observations read from the data set SASHELP.SHOES.
Can't get it output, tho' ? :) I'm lost...
||6/21/2007 2:58:30 PM