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 (October 2005, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 27 Oct 2005 15:02:04 -0500
Reply-To:     PuddingDotManAtGmailDotCom@listserv.cc.uga.edu
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Pudding Man <pudding.man@GMAIL.COM>
Subject:      Re: Parsing a complicated data file
Comments: To: Kimberly Anne <kimmerz321@gmail.com>
In-Reply-To:  <1130438095.060072.288630@g49g2000cwa.googlegroups.com>
Content-Type: text/plain; charset=ISO-8859-1

You might want to take a peek at line and column pointers that can be used with the INPUT statement.

This illustrates one such approach:

data _null_; policy = 493; file 'dum.dat' lrecl=132 pad; put #2 @8 policy 3. @20 'Blind Boy Fuller' #5 @45 '1415 Aardvark Ln, Scrunch City, OK 99999' #24; run;

data disstuff; infile 'dum.dat' lrecl=132; input #2 @8 policy 3. @20 name :&$20. #5 @45 address :&$50. #24; put _all_; run;

That such should be hep'ful ...

Prost, Puddin'

***************************************************************** *** Puddin' Man PuddingDotMan at GmailDotCom ** *****************************************************************;

On 10/27/05, Kimberly Anne <kimmerz321@gmail.com> wrote: > Hi all, > > I have a somewhat complicated text file that I want to parse. > > For each observation, there are 24 lines of text that contain the > information I need, each with a carriage return at the end. On some > lines, I want to get several pieces of information. On others, I only > need one piece. On others, I don't want any of the information - I > just want to skip over them. > > I know where the data I want to get at in each line is (i.e. a policy > number is in position 8 in line 2 and is 3 digits long, a name is in > position 20 on line 2 and is 20 characters long, an address is in > position 45 on line 5 and is 50 characters long), but I'm not sure how > to parse this. I was trying to use an array to grab each line, > thinking i could just parse each element, but SAS is giving me errors > when I try to use INPUT with an array. > > If anybody has any suggestions, I'd love to hear them. Thanks! > > Kim >


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