Date: Fri, 6 Jun 2008 00:25:15 +0000
Reply-To: Paul Dorfman <sashole@BELLSOUTH.NET>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Paul Dorfman <sashole@BELLSOUTH.NET>
Subject: Re: Creating a second dimension
Watch program control:
1. First record from first buffer is read.
2. Do-loop reads all records from the second buffer one by one and outputs the obsa.
3. Program control leaves the loop, returns to the top of the step, hits the first SET, and reads the second record from its buffer.
4. Program control enters the DO-loop again. Although by the time, EOF=1, because of UNTIL it executes the second SET. However, its buffer is already empty - the DO-loop has exhausted it during the first iteration of the implied loop - and the step stops.
The reason your code looks reasonable but does not work is that a sequential SET does not have the ability to rewind the file pointer to the beginning of a particular buffer: Once it is empty, it is empty. To rectify that, a direct-read SET is needed, which is what Mike Zdeb used in his solution. A direct-read SET has no concept of end of file, which is why a step with a lone direct-access SET must be STOPped forcibly. In Mike's solution, the step stops when program control hits the sequential SET after it has read all the records from its buffer.
-------------- Original message from yingtao <yingtaoliu@GMAIL.COM>: --------------
> I am just wondering why the DOW tech not working as below:
> It just stops at the 2nd implicit loop. even if I force eof=1 before
> set statement.
> data have;
> input cola : $1. @@;
> A B C
> data need;
> set have;
> do until(eof);
> set have(rename=(cola=colb)) end=eof;