<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Reading records spread over a varying number of lines in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Reading-records-spread-over-a-varying-number-of-lines/m-p/276857#M55512</link>
    <description>&lt;P&gt;Thanks for that, works well with a Retain so is the best solution for now I think&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data want;

length name $ 30;

length segment $ 20;

input segment &amp;amp;;
retain name;

if segment='begin name' then name=' ';

else if segment='end name' then&amp;nbsp;
&amp;nbsp; &amp;nbsp;do;
&amp;nbsp; &amp;nbsp; &amp;nbsp; drop segment;
&amp;nbsp; &amp;nbsp; &amp;nbsp; output;
&amp;nbsp; &amp;nbsp;end;
else name = cats(name, segment);



datalines;
begin name
pe
te
smi
th
end name
begin name
joh
n
br
o
wn
end name

run;&lt;/PRE&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;</description>
    <pubDate>Mon, 13 Jun 2016 07:35:24 GMT</pubDate>
    <dc:creator>Brad5000</dc:creator>
    <dc:date>2016-06-13T07:35:24Z</dc:date>
    <item>
      <title>Reading records spread over a varying number of lines</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-records-spread-over-a-varying-number-of-lines/m-p/276765#M55486</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I'm trying to read values from a text file but unfortunately they're held in pretty weird format, for example the names 'Pete Smith' and 'John Brown' could be held like this;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;name begin
pe
te
smi
th
end name
begin name
joh
n
br
o
wn
end name
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Is it possible to read these into a dataset using a single input statement or would it need a combination of several inputs? Any advice would be appreciated.&lt;/P&gt;</description>
      <pubDate>Sun, 12 Jun 2016 14:29:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-records-spread-over-a-varying-number-of-lines/m-p/276765#M55486</guid>
      <dc:creator>Brad5000</dc:creator>
      <dc:date>2016-06-12T14:29:30Z</dc:date>
    </item>
    <item>
      <title>Re: Reading records spread over a varying number of lines</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-records-spread-over-a-varying-number-of-lines/m-p/276779#M55494</link>
      <description>&lt;P&gt;A DATA step could handle this except for one feature. &amp;nbsp;How do you know when the first name ends and the last name begins?&lt;/P&gt;</description>
      <pubDate>Sun, 12 Jun 2016 16:34:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-records-spread-over-a-varying-number-of-lines/m-p/276779#M55494</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-06-12T16:34:19Z</dc:date>
    </item>
    <item>
      <title>Re: Reading records spread over a varying number of lines</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-records-spread-over-a-varying-number-of-lines/m-p/276786#M55496</link>
      <description>&lt;P&gt;Hi, yes that's a problem, I think for now I would just like to get them into a single variable.&lt;/P&gt;</description>
      <pubDate>Sun, 12 Jun 2016 18:52:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-records-spread-over-a-varying-number-of-lines/m-p/276786#M55496</guid>
      <dc:creator>Brad5000</dc:creator>
      <dc:date>2016-06-12T18:52:34Z</dc:date>
    </item>
    <item>
      <title>Re: Reading records spread over a varying number of lines</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-records-spread-over-a-varying-number-of-lines/m-p/276807#M55500</link>
      <description>&lt;P&gt;OK, here's one way.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;length name $ 30;&lt;/P&gt;
&lt;P&gt;retain name;&lt;/P&gt;
&lt;P&gt;length segment $ 20;&lt;/P&gt;
&lt;P&gt;input segment &amp;amp;;&lt;/P&gt;
&lt;P&gt;if segment='begin name' then name=' ';&lt;/P&gt;
&lt;P&gt;else if segment='end name' then output;&lt;/P&gt;
&lt;P&gt;else name = cats(name, segment);&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But the problem of identifying the separation point between first and last name still exists.&lt;/P&gt;</description>
      <pubDate>Sun, 12 Jun 2016 22:57:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-records-spread-over-a-varying-number-of-lines/m-p/276807#M55500</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-06-12T22:57:37Z</dc:date>
    </item>
    <item>
      <title>Re: Reading records spread over a varying number of lines</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-records-spread-over-a-varying-number-of-lines/m-p/276825#M55503</link>
      <description>&lt;P&gt;Attach a TEXT file to let us test it.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jun 2016 01:33:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-records-spread-over-a-varying-number-of-lines/m-p/276825#M55503</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-06-13T01:33:26Z</dc:date>
    </item>
    <item>
      <title>Re: Reading records spread over a varying number of lines</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-records-spread-over-a-varying-number-of-lines/m-p/276846#M55510</link>
      <description>&lt;P&gt;With data like that: impossible.&lt;/P&gt;
&lt;P&gt;Simply because you cannot state a clear rule where words are separated; one coould only read in the names as strings without delimiters.&lt;/P&gt;
&lt;P&gt;You first need a clear rule where the given name ends and the surname begins, then you can think about code.&lt;/P&gt;
&lt;P&gt;The code would then actually be very simple.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jun 2016 05:48:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-records-spread-over-a-varying-number-of-lines/m-p/276846#M55510</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-06-13T05:48:15Z</dc:date>
    </item>
    <item>
      <title>Re: Reading records spread over a varying number of lines</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-records-spread-over-a-varying-number-of-lines/m-p/276857#M55512</link>
      <description>&lt;P&gt;Thanks for that, works well with a Retain so is the best solution for now I think&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data want;

length name $ 30;

length segment $ 20;

input segment &amp;amp;;
retain name;

if segment='begin name' then name=' ';

else if segment='end name' then&amp;nbsp;
&amp;nbsp; &amp;nbsp;do;
&amp;nbsp; &amp;nbsp; &amp;nbsp; drop segment;
&amp;nbsp; &amp;nbsp; &amp;nbsp; output;
&amp;nbsp; &amp;nbsp;end;
else name = cats(name, segment);



datalines;
begin name
pe
te
smi
th
end name
begin name
joh
n
br
o
wn
end name

run;&lt;/PRE&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Mon, 13 Jun 2016 07:35:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-records-spread-over-a-varying-number-of-lines/m-p/276857#M55512</guid>
      <dc:creator>Brad5000</dc:creator>
      <dc:date>2016-06-13T07:35:24Z</dc:date>
    </item>
    <item>
      <title>Re: Reading records spread over a varying number of lines</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-records-spread-over-a-varying-number-of-lines/m-p/276858#M55513</link>
      <description>Yes that is an issue, for now getting everything into a single variable will have to do.</description>
      <pubDate>Mon, 13 Jun 2016 07:39:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-records-spread-over-a-varying-number-of-lines/m-p/276858#M55513</guid>
      <dc:creator>Brad5000</dc:creator>
      <dc:date>2016-06-13T07:39:24Z</dc:date>
    </item>
  </channel>
</rss>

