LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (May 2005, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Mon, 23 May 2005 10:37:18 +1000
Reply-To:   Scott Bass <usenet739_yahoo_com_au@ALFREDO.CC.UGA.EDU>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Scott Bass <usenet739_yahoo_com_au@ALFREDO.CC.UGA.EDU>
Subject:   I wish SAS would allow a *string* as a field delimiter
Comments:   To: sas-l@uga.edu

Hi,

(for brevity, this post is a simplified example of a more complex problem...)

Summary: Is there a way to make SAS accept a *string* of characters as a field delimiter when reading a flat file? From the docs, it looks like NO (rats!) but thought I'd ask.

Details: I have to read in a file with embedded carriage returns in the fields. I note Richard DeVenezia's post on how to do this: http://listserv.uga.edu/cgi-bin/wa?A2=ind0206D&L=sas-l&P=R33076.

Say this is the sample file:

This is record 1, VAR1

With one embedded carriage return ===== This is record 1, VAR2

With two embedded carriage returns Oops, and a =line= containing a single = character ===== This is record 1, VAR3

With three embedded carriage returns ===== This is record 2, VAR1

With one embedded carriage return ===== ===== This is record 2, VAR3

With three embedded carriage returns =====

What I want is two observations, three vars, embedded CRs in the vars. For obs 2, var2 is missing.

I *wish* I could say:

data foo; infile 'c:\temp\arbitrary.txt' recfm=n dsd dlm='====='; /* or perhaps "\n=====\n" in hex */

length var1-var3 $5000;

input var1-var3;

... any additional processing ... ; run;

but dlm only accepts a single character for the delimiter. Bummer.

Rationale: I'd like the input file to be "human readable". If I change the delimiter to Tab, #, etc, the file is hard to "human" read. If I could specify the exact *string* I want to delimit fields, it would be easier to accomplish this.

(The actual "file" is a PIPE to a Perl script. Another (ugly) option is a command line switch to have two output types: one for SAS import, and the other for STDOUT)

Any bright ideas, O gurus of SAS-L?

Regards, Scott

P.S.: SAS v8.2, Windows


Back to: Top of message | Previous page | Main SAS-L page