Date: Thu, 11 Mar 1999 09:59:56 -0500
Reply-To: Bernard Tremblay <bernard@CAPITALE.QC.CA>
Sender: "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From: Bernard Tremblay <bernard@CAPITALE.QC.CA>
Subject: Re: SAS OUTPUT Question
Hi,
The main problem of you code is the "else delete;" this instruction
tell SAS to leave the current loop and cycle into a new data step loop...
Not the effect desired!
You should use the "continue" instruction instead of the delete.
Or better use the 'select' construction. This a perfect case of it!
Next problem: there is no check for end of file in the loop
construct. You may (and probably will) get an end of file during the loop!
You should output whatever you have and terminate.
Since you are obtaining all values in a 'do' loop construct, you
don't need to retain anything.
Last problem, but not least: you should not use the trailing '@'
if you input in column. You'll end up reading five time the same line...
Here is an example of what you could code:
>>>DATA SYSDATA1 (KEEP=DATE HOUR);
>>> INFILE INPUT1;
>>> DO I=1 TO 5 while(^eof);
>>> INPUT FLD1 $ 03-06 FLD2 $ 18-24 ;
select(fld1);
when('TIME') HOUR = SUBSTR(FLD2,1,2);
when(DATE') DATE = FLD2;
otherwise;
end;
>>> END;
>>> OUTPUT SYSDATA1;/*You could check for incomplete 5 records block here*/
run;
I hope it helps,
Bernard Tremblay
\\\|///
\\ - - //
( @ @ )
+-----oOOo-(_)-oOOo-------+--------------------------------------+
| Bernard Tremblay | |
| La Capitale | Tel: (418) 646-2401 |
| | Fax: (418) 646-5960 |
| | Int: Bernard.Tremblay@capitale.qc.ca |
+-------------------------+--------------------------------------+
| Imaginasys enr | Res: (418) 658-1411 |
| | Int: bertrem@quebectel.com |
+--------------Oooo-------+--------------------------------------+
oooO ( )
( ) ) /
\ ( (_/
\_)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~>>>
Date: Wed, 10 Mar 1999 11:29:01 -0500
>>>From: "Janas, James W" <james.janas@EDS.COM>
>>>Subject: SAS OUTPUT Question
>>>
>>>Hope someone can help me out. I am running on OS390 system. I have spun off
>>>a JES2 sysout to disk. Each page of the sysout has 5 lines of data.
>>>Everytime I read a record from the sysout SAS is outputing a record. Is
>>>there a way I can read 5 input records and create one SAS record?
>>>
>>>
>>>Here is the test code I have been running:
>>>
>>>DATA SYSDATA1 (KEEP=DATE HOUR);
>>>RETAIN DATE HOUR;
>>> DO I=1 TO 5;
>>> INFILE INPUT1;
>>> INPUT
>>> FLD1 $ 03-06 FLD2 $ 18-24@;
>>> IF FLD1 = 'TIME' THEN HOUR = SUBSTR(FLD2,1,2);
>>> ELSE
>>> IF FLD1 = 'DATE' THEN DATE = FLD2;
>>> ELSE DELETE;
>>> END;
>>> OUTPUT SYSDATA1;
>>>
>>>Thanks in advance,
>>>Jim