Date: Thu, 28 Aug 2003 10:52:21 -0400
Reply-To: Ian Whitlock <WHITLOI1@WESTAT.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Ian Whitlock <WHITLOI1@WESTAT.COM>
Subject: Re: input specific lines with overlapping input?
Content-Type: text/plain
Arthur,
As a matter of style, I would prefer two steps to make the intent clearer.
data a ;
infile cards firstobs = 2 obs = 2 ;
input (achar1-achar7) ($char1.) ;
cards ;
aa
1234567
cccc
dddd
eeeee1234
eeeeeeeee
eeeee5678
;
data b ;
infile cards firstobs = 5;
input @6 (echar1-echar4) ($char1.) ;
cards ;
aa
1234567
cccc
dddd
eeeee1234
eeeeeeeee
eeeee5678
;
One advantage to this second approach is that it produces consistent results
when the data is read from an external data set with trailing blanks
removed.
IanWhitlock@westat.com
-----Original Message-----
From: Arthur Ellen [mailto:arte@PANIX.COM]
Sent: Thursday, August 28, 2003 7:37 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: input specific lines with overlapping input?
/* reading specific lines with overlapping input */
/* is there a better way to go to just line 2 and read it or a portion of it
and then go to line 4 and read an overlapping piece of it? */
data a(keep=achar1-achar7) b(keep=echar1-echar4);
input (achar1-achar7) ($char1.) @6 (echar1-echar4)($char1.);
if _n_=2 then output a;
if _n_>4 then output b;
cards;
aa
bbbbbbb
cccc
dddd
eeeeeeeee
eeeeeeeee
eeeeeeeee
;
proc print data=a;
proc print data=b;
run;