Re: Questions to Dorfman's DO UNTIL loop #4

  • Follow


On Thu, 21 Jun 2007 14:02:54 +0000, Ian Whitlock <iw1junk@COMCAST.NET>
wrote:

>Summary: The implied loop of the DATA step is driven by input.
>#iw-value=1
>
>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;
>>     end;
>>     put 'after set iteration' _n_ 2.;
>>   run ;
>
>and wrote:
>
>>   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.
>
>Perhaps
>
>   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" ;
>     end;
>     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.
>
>Ian Whitlock

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;
628      end;
629      put 'after set1 iteration' _n_ 2.;
630      set sashelp.shoes; *end=finito;
631      put 'after set2 iteration' _n_ 2.;
632  run;

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...

Thanks, Arild
0
Reply sko (123) 6/21/2007 2:58:30 PM


0 Replies
20 Views

(page loaded in 0.062 seconds)

Similiar Articles:













7/30/2012 7:14:23 PM


Reply: