| Date: | Tue, 10 Jul 2007 06:48:11 -0700 |
| Reply-To: | vldesilva@GMAIL.COM |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | vldesilva@GMAIL.COM |
| Organization: | http://groups.google.com |
| Subject: | Re: import text files |
|
| In-Reply-To: | <OF8812B9E1.BC4D3536-ON85257313.006CC654-85257313.006CE4EA@dom.com> |
| Content-Type: | text/plain; charset="us-ascii" |
|---|
On Jul 9, 3:49 pm, Nathaniel.Wood...@DOM.COM (Nat Wooding) wrote:
> Here is another solution which uses the automatic SAS variable _infile_
> which is a way to look at the imput line before you read it as variables.
>
> Data Intext;
>
> filename indata 'c:\park\blahblah.txt';
> infile indata;
>
> input @; * read and hold the line in a buffer until we decide what to do
> with it;
>
> INFORMAT CHAR1 $4. NUM1 8. CHAR2 $1. NUM2 8. CHAR3 $3.;
> RETAIN CHAR1 NUM1;
>
> if _infile_=:'----' or _infile_ =: 'Date' then delete;
>
> if _infile_ =:'FHQC' THEN DO;
> INPUT @1 CHAR1 NUM1;
> RETURN;
> END;
>
> INPUT CHAR2 NUM2 CHAR3;
> OUTPUT;
> RUN;
>
> Proc Print;
> run;
>
> Nat Wooding
> Environmental Specialist III
> Dominion, Environmental Biology
> 4111 Castlewood Rd
> Richmond, VA 23234
> Phone:804-271-5313, Fax: 804-271-2977
>
> vldesi...@GMAIL.C
> OM
> Sent by: "SAS(r) To
> Discussion" S...@LISTSERV.UGA.EDU
> <S...@LISTSERV.U cc
> GA.EDU>
> Subject
> import text files
> 07/09/2007 01:39
> PM
>
> Please respond to
> vldesi...@GMAIL.C
> OM
>
> 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.
>
> -----------------------------------------
> CONFIDENTIALITY NOTICE: This electronic message contains
> information which may be legally confidential and/or privileged and
> does not in any case represent a firm ENERGY COMMODITY bid or offer
> relating thereto which binds the sender without an additional
> express written confirmation to that effect. The information is
> intended solely for the individual or entity named above and access
> by anyone else is unauthorized. If you are not the intended
> recipient, any disclosure, copying, distribution, or use of the
> contents of this information is prohibited and may be unlawful. If
> you have received this electronic transmission in error, please
> reply immediately to the sender that you have received the message
> in error, and delete it. Thank you.
Is there any way to say if _infile_=:'DATE ' then skip (delete) the
next 8 lines includingthe current line or delete lines until
_infile_:='----'
|