Date: Thu, 21 Feb 2008 11:26:55 -0500
Reply-To: "data _null_," <datanull@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "data _null_," <datanull@GMAIL.COM>
Subject: Re: Line feed characters in delimited input files
In-Reply-To: <7367b4e20802210815v744b6b33v81094a80121d0559@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1
I'm don't expect you need this but here is a work around that seems
reasonable. It use RECFM=N and SHAREBUFFERS.
The must be something about TERMSTR that I don't understand.
filename ft44f001 temp;
data _null_;
file ft44f001 termstr=crlf;
do _n_ = 1 to 10;
put 'Does this' '0a'x 'work?';
end;
run;
data _null_;
retain b;
infile ft44f001 sharebuffers recfm=n;
file ft44f001;
input a $char1.;
if a eq '0a'x and b ne '0d'x then put ' ';
b = a;
run;
data _null_;
infile ft44f001 termstr=crlf;
input;
list;
run;
On Thu, Feb 21, 2008 at 11:15 AM, data _null_, <datanull@gmail.com> wrote:
> I had hopes for INFILE option TERMSTR but this test does not produce
> the desired result. '0a'X still causes a new line.
>
> filename ft44f001 temp;
> data _null_;
> file ft44f001;
> put 'Does this' '0a'x 'work?';
> run;
> data _null_;
> infile ft44f001 termstr=crlf;
> input;
> list;
> run;
>
>
> 181 filename ft44f001 temp;
> 182 data _null_;
> 183 file ft44f001;
> 184 put 'Does this' '0a'x 'work?';
> 185 run;
>
> NOTE: The file FT44F001 is:
> File Name=F:\Temp\SAS Temporary Files\_TD9016\#LN00025,
> RECFM=V,LRECL=256
>
> NOTE: 1 record was written to the file FT44F001.
> The minimum record length was 15.
> The maximum record length was 15.
>
>
> 186 data _null_;
> 187 infile ft44f001 termstr=crlf;
> 188 input;
> 189 list;
> 190 run;
>
> NOTE: The infile FT44F001 is:
> File Name=F:\Temp\SAS Temporary Files\_TD9016\#LN00025,
> RECFM=V,LRECL=256
>
> RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+---
> 1 Does this 9
> 2 work? 5
> NOTE: 2 records were read from the infile FT44F001.
> The minimum record length was 5.
> The maximum record length was 9.
>
>
> On Thu, Feb 21, 2008 at 10:31 AM, John Whittington
> <John.W@mediscience.co.uk> wrote:
> > Hi folks,
> >
> > It's a very long time since I showed my face here. I do try to keep my eye
> > on SAS-L traffic, but do not seem to have had the time to contribute for
> > longer than I can recall - although I hope that may be changing.
> >
> > Anyway, I have a small problem with which I would value some assistance.
> >
> > I have some input data sets provided to me which are .csv files created by
> > Excel, which I am reading into SAS with DSD. Some of the fields are free
> > text ones, and those creating the original Excel worksheets have clearly
> > put forced line breaks within some of the entries, which has the result of
> > putting a LineFeed (OAx) character into the .csv file.
> >
> > Needless to say, when such entries hit my SAS INPUT statement, everything
> > goes wrong. In essence, the LineFeed character seems to be interpreted as
> > the end of the input record, but that same record is 'held' for the next
> > iteration fo the DATA step.
> >
> > I obviously could pre-process the data in some way, to change these 0Ax
> > characters to something else, but I suspect that there may be a much easier
> > way. Ideally, I would retain some indication of where those LineFeed
> > characters were, so I could recreate the format of the original text entry
> > if I ever needed to.
> >
> > TIA for any suggestions.
> >
> > Kind Regards,
> >
> > John
> >
> > ----------------------------------------------------------------
> > Dr John Whittington, Voice: +44 (0) 1296 730225
> > Mediscience Services Fax: +44 (0) 1296 738893
> > Twyford Manor, Twyford, E-mail: John.W@mediscience.co.uk
> > Buckingham MK18 4EL, UK
> > ----------------------------------------------------------------
> >
>
|