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 (July 2007, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 9 Jul 2007 11:38:27 -0700
Reply-To:     "Duell, Bob" <BD9439@ATT.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Duell, Bob" <BD9439@ATT.COM>
Subject:      Re: import text files
Comments: To: vldesilva@GMAIL.COM
In-Reply-To:  A<1184002782.071728.135770@o61g2000hsh.googlegroups.com>
Content-Type: text/plain; charset="us-ascii"

There are probably many ways to do this. Here's one (which depends a lot on assumptions about your file):

data a(keep=FHQC some_var d_or_h some_other_var A_var); retain FHQC 'FHQC' some_var; informat C_var $4. d_or_h $1. A_var $3.; input C_Var @; if C_var = 'FHQC' then input some_var; else if C_var = '----' then do; input; c_var = ' '; do until (c_var = '----'); input C_Var ; end; end; else do; d_or_h = c_var; input some_other_var A_var; output; end; datalines; FHQC 121 H 1234 A14 FHQC 123 D 1235 A14 D 1235 A15 FHQC 124 ---------------------------- Date: blah blah ---------------------------- D 1236 A15 run;

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of vldesilva@GMAIL.COM Sent: Monday, July 09, 2007 10:40 AM To: SAS-L@LISTSERV.UGA.EDU Subject: import text files

Hello all,

I hvae a text file having a format like below

FHQC 121 H 1234 A14 FHQC 123 D 1235 A14 D 1235 A15 FHQC 124 ---------------------------- Date: blah blah ---------------------------- D 1236 A15

I wan to create a SAS data set that looks like the following

FHQC 121 H 1234 A14 FHQC 123 D 1235 A14 FHQC 123 D 1235 A15 FHQC 124 D 1236 A15

The problem is The lines after FHQC can be 1 or more. It is not a fixed number of lines. And I also want to ignore the lines in the middle like ---------------------------- Date ----------------------------

What is the easiest way of going about doing this. Appreciate your input.


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