Date: Thu, 25 Apr 1996 01:55:45 +0100
Reply-To: John Whittington <johnw@MAG-NET.CO.UK>
Sender: "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From: John Whittington <johnw@MAG-NET.CO.UK>
Subject: Re: two delimiters on infile statement
On Wed, 24 Apr 1996, Rodney Presley <rpresley@CCLINK.FHCRC.ORG> wrote:
>I am reading in a tab delimited file produced by an Excel
>spreadsheet. Excel got the file from another format and in the
>process of turning the file into a spreadsheet Excel placed
>quotation (") marks around text fields. Therefor, I need an
>infile statement with two delimiters TFM manual gives an example
>such as:
>infile filename dlm='AB';
>
>I can read tab delimited fields with this statement:
>infile filename dlm='09'x ;
>This of course does not recognize the quotation marks as
>delimiters.
>
>Various attempts to specify both delimiters have failed Help
>will be appreciated.
Rodney, the trick to overcome the problem you have described is to
concatenate the desired limiters together into a variable, and then use this
variable for your delimiter definition - i.e.:
zzz = '09'x||'"' ;
infile filename dlm=zzz ;
The only 'danger' exists if there are tabs around even those fields which
have been enclosed in quotes AND there are spaces between the quote marks
and tab characters; were that to happen the quote mark and tab would be
taken as separate delimiters, delimiting the space(s) between them, which
would then be interpreted as an addition filed (variable) - messing
everything up!
If the file has tab delimiters between ALL fields, even those that have been
enclosed in quotes, then an alternative approach (which avoids the 'danger'
just described) is to use the DSD option of INFILE - i.e.:
infile filename dlm='09'x DSD ;
The DSD option deals with (i.e. removes) the quote marks and also results in
consecutive delimiters (with no intervening space) being interpreted as
indicating missing vales between them (without DSD multiple consecutive
delimiters are treated as if they were one).
Any help?
John
-----------------------------------------------------------
Dr John Whittington, Voice: +44 1296 730225
Mediscience Services Fax: +44 1296 738893
Twyford Manor, Twyford, E-mail: johnw@mag-net.co.uk
Buckingham MK18 4EL, UK CompuServe: 100517,3677
-----------------------------------------------------------