Date: Wed, 20 Jun 2001 12:10:42 -0400
Reply-To: Howard Schreier <Howard_Schreier@ITA.DOC.GOV>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Howard Schreier <Howard_Schreier@ITA.DOC.GOV>
Subject: Re: Reading varying length record with datalines
An answer, and a new question ...
Here's a way which depends on the V.7 and later availability of the _INFILE_
automatic variable:
data whatever;
length var2 $ 60;
input var1 $;
var2 = left(substr(_infile_,index(_infile_,var1)+length(var1)));
datalines;
house My house is my castle.
cat It is raining cats and dogs
method This method won't work in V.6 and earlier
work I don't see why it fails to work on this record
or for that matter here too
;
The results:
var1 var2
house My house is my castle.
cat It is raining cats and dogs
method This method won't work in V.6 and earlier
work ork I don't see why it fails to work on this record
or r for that matter here too
Why does it fail for the last two test records? I have no idea.
On Wed, 20 Jun 2001 10:44:00 +0200, Dietrich Alte
<alte@MAIL.UNI-GREIFSWALD.DE> wrote:
>Hi all,
>
>I have records like
>
>Var1 Var2
>---------------------------
>house My house is my castle.
>cat It is raining cats and dogs
>
>and want to read them from datalines in one step.
>
>In the infile statement you can state truncover and/or use the varying
>format in order to read the sentence into one variable.
>
>How can this be achieved? Truncover doesn't work with datalines, for
>the varying format I need a length variable, but the statement length
>ist not abailable.
>
>Any help welcome.
>
>TIA
>
>--
>-----------------------------------------------------------------
> Dietrich Alte (Statistician, Dipl.-Stat.)
> University of Greifswald - Medical Faculty
> Institute of Epidemiology and Social Medicine
> Walther-Rathenau-Str. 48, D-17487 Greifswald, Germany
> Phone +49 (0) 3834 - 86 77 13, fax +49 (0) 3834 - 86 66 84
> Email alte@mail.uni-greifswald.de
> Institute http://www.medizin.uni-greifswald.de/epidem/
> Study http://www.medizin.uni-greifswald.de/epidem/ship.htm
>-----------------------------------------------------------------