Date: Fri, 29 Jul 2005 17:50:35 -0400
Reply-To: Don Henderson <donaldjhenderson@HOTMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Don Henderson <donaldjhenderson@HOTMAIL.COM>
Subject: Re: Pop Quiz
Content-Type: text/plain; format=flowed; charset="iso-8859-1";
reply-type=original
Paul,
You are correct. In my haste to reply, I focused on the infinite loop and
did not think that part completely thru.
Regards,
-don
p.s., on the issue of resources used, the third case is still infinite and
is exacerbated now by the fact that no observations are ever written and so
it won't be limited by work space. The difference in resources for WHO and
WHAT is noise (repeated executions of those two will yield differences that
are less than the difference between them).
----- Original Message -----
From: "Dorfman, Paul" <paul.dorfman@FCSO.COM>
To: <SAS-L@LISTSERV.UGA.EDU>; "Don Henderson" <donaldjhenderson@HOTMAIL.COM>
Sent: Friday, July 29, 2005 4:59 PM
Subject: Re: Pop Quiz
> Don,
>
> How will #3 write anything out without having ever executed OUTPUT? The IF
> failing on I=1, J=1 always returns control before first DO without ever
> falling down to the OUTPUT statement. If the subsetting IF and OUTPUT
> swapped places, then but of course...
>
> Kind regards
> ----------------
> Paul M. Dorfman
> Jacksonville, FL
> ----------------
>
>
> On Fri, 29 Jul 2005 16:43:14 -0400, Don Henderson
> <donaldjhenderson@HOTMAIL.COM> wrote:
>
>>Based on a very quick look:
>>
>>100
>>0
>>Infinite (really the max number that will fit until you run out of work
>>space). This is an infinite loop.
>>
>>Clearly the last one takes the most resources.
>>
>>Rationale:
>>
>>- 100 should be obvious :-).
>>
>>- 0 because you apply a subsetting IF on the first cycle thru where I=1
> and
>>J=1. Condition not true, controls returns to the "supervisor" and since
>>there was no input source, execution stops. Since there was an explicit
>>OUTPUT statement, but it was not executed, SAS does not do its default
>>output. The result is no obs
>>
>>- Infinite because there is nothing to stop the data step from executing.
>>There is a set statement, so the supervisor will invoke the step
> repeatedly
>>until at least one of the input sources reads "end of file." Since the
> only
>>SET uses the POINT option, that never happens.
>>
>>Regards,
>>-don h
>>
>>p.s., as an interesting wrinkle on the third case, way back when the POINT
>>option first came out, it was documented in a tech report. There was an
>>example that appeared to be complete on the right hand page in the doc.
>>However there was one statement on the next page (which you only saw if
> you
>>turned the page) - the STOP statement. I was an instructor for SAS at the
>>time and there was more than one user who had keyed in the program and had
>>not included the STOP statement as they had not turned the page :-).
>>
>>-----Original Message-----
>>From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Jack
>>Hamilton
>>Sent: Friday, July 29, 2005 2:06 PM
>>To: SAS-L@LISTSERV.UGA.EDU
>>Subject: Pop Quiz
>>
>>Without running the code, how many observations do you think will be in
>>WHO, WHAT, and WHERE, and what will the relative timings be?
>>
>>=====
>>data who;
>> do i = 1 to 10;
>> do j = 1 to 10;
>> output;
>> end;
>> end;
>>run;
>>
>>data what;
>> do i = 1 to 10;
>> do j = 1 to 10;
>> if j = 5;
>> output;
>> end;
>> end;
>>run;
>>
>>data when;
>> do i = 1 to 10;
>> do j = 1 to 10;
>> set sashelp.prdsale point=i;
>> if j = 5;
>> output;
>> end;
>> end;
>> stop;
>>run;
>>=====
>>
>>I recommend against running this code yourself. Answers Monday.
>
|