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 (June 1999, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 11 Jun 1999 15:47:10 -0400
Reply-To:     Howard Schreier <Howard_Schreier@ITA.DOC.GOV>
Sender:       "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From:         Howard Schreier <Howard_Schreier@ITA.DOC.GOV>
Subject:      Reading EDI Transaction Sets in SAS--DSD and FLOWOVER
Content-Type: text/plain; charset=US-ASCII

Maybe if you put in a couple of GOTO's :-)

Seriously, I remember once having a problem like this. I let the INPUT statement read entire physical records and wrote my own DATA step code to parse for the logical segments. The SCAN function is the best candidate.

The trick is to look ahead and detect when you are about to process the last (possibly incomplete) logical segment of a physical record. Before extracting it, discard the preceding segments, read the next record, and concatenate.

If you follow the logic, you will see that you need a workspace in the form of a character variable long enough to hold two physical records. This can be a serious constraint with SAS v. 6, though your 80-character records are fortunately short enough. You do not say what the maximum logical segment length is. If it is high enough that a segment could span three or more records (that is, wrap more than once), things get messier.

Other tricky things are initialization, termination, and the special case in which logical and physical boundaries coincide.

> From: "Berryhill, Timothy" <TWB2@PGE.COM> > Subject: Reading EDI Transaction Sets in SAS--DSD and FLOWOVER > > Is anyone reading EDI transaction sets in SAS? > > The ones I am getting are logically variable length records with arbitrary > delimiters (* between fields, } between segments, but the exact values are > not important and may vary from file to file). The files are physically > fixed length records. On small machines, there is a '0D'x or a '0D0A'x (a > carriage return or a carriage return line feed) after every 80 characters, > and on the mainframe the file is just a fixed length record file with a > length of 80. Field values may wrap from one line to the next. > > I am attempting to read the file with code similar to: > DATA RAW; > INFILE MYFILE DSD DLM='*}' FLOWOVER END=TIRED; > DO UNTIL (TIRED); > INPUT PIECE @@ ; > OUTPUT; > END; > RUN; > > The problem is that despite both the explicit DLM= option and the FLOWOVER > option, the end of the line is treated as a delimiter. Field values which > wrap to a new line are picked up in two parts, rather than as a single > piece. > > I am trying something using the COLUMN= option, but the column pointer goes > to 81 whether the character in column 80 is a delimiter or not. I may have > to compare the change in the column pointer to the length of the peice > returned--but the pieces can have trailing blanks which LENGTH will ignore. > > Any suggestions?

(signed) Howard_Schreier@ita.doc.gov


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