<?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 in multiple input lines into one one observation and concatenating in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Reading-in-multiple-input-lines-into-one-one-observation-and/m-p/497285#M131757</link>
    <description>Figured.</description>
    <pubDate>Thu, 20 Sep 2018 09:07:57 GMT</pubDate>
    <dc:creator>Sha88</dc:creator>
    <dc:date>2018-09-20T09:07:57Z</dc:date>
    <item>
      <title>Reading in multiple input lines into one one observation and concatenating</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-in-multiple-input-lines-into-one-one-observation-and/m-p/496887#M131537</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm having some trouble reading in a file into SAS,&amp;nbsp; it is an ASCII carrot ^ delimited file.&amp;nbsp; &amp;nbsp;The first variable contains a record type and then other data follows,&amp;nbsp; &amp;nbsp;Until you get to A records where there is a second record type followed by data.&amp;nbsp; &amp;nbsp;I need to read in multiple rows for&amp;nbsp;each&amp;nbsp;record type and concatenate them into a single variable within an observation, can this be done?&amp;nbsp; &amp;nbsp;E.g. below,&amp;nbsp; &amp;nbsp;&lt;EM&gt;I have already gotten the P, V and R lines into one observation using 'retain' and select while,&amp;nbsp; just don't know how to concat the A^A and A^B into one before inserting into one variable.&amp;nbsp;&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Source File e.g.:&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;P^JOHN^SMITH^26^1000101&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;V^VISIT 1^01DEC2019&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;R^RED BLOOD CELLS^10^u/ml&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="1 2 3 4 5 6 7" color="#FF0000"&gt;A^A^COMMENTS ABOUT THIS&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="1 2 3 4 5 6 7" color="#FF0000"&gt;A^A^TEST THAT APPEAR ON&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="1 2 3 4 5 6 7" color="#FF0000"&gt;A^A^DIFFERENT LINES&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="1 2 3 4 5 6 7" color="#0000FF"&gt;A^B^MORE COMMENTS ON A&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="1 2 3 4 5 6 7" color="#0000FF"&gt;A^B^DIFFERENT LINE THAT&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="1 2 3 4 5 6 7" color="#0000FF"&gt;A^B^BELONG IN A DIFFERENT&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="1 2 3 4 5 6 7" color="#0000FF"&gt;A^B^COLUMN&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;R^WHITE BLOOD CELLS^22^u/ml&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="1 2 3 4 5 6 7" color="#FF0000"&gt;A^A^COMMENTS ABOUT THIS&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="1 2 3 4 5 6 7" color="#FF0000"&gt;A^A^TEST THAT APPEAR ON&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="1 2 3 4 5 6 7" color="#FF0000"&gt;A^A^DIFFERENT LINES&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="1 2 3 4 5 6 7" color="#0000FF"&gt;A^B^MORE COMMENTS ON A&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="1 2 3 4 5 6 7" color="#0000FF"&gt;A^B^DIFFERENT LINE THAT&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="1 2 3 4 5 6 7" color="#0000FF"&gt;A^B^BELONG IN A DIFFERENT&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="1 2 3 4 5 6 7" color="#0000FF"&gt;A^B^COLUMN&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT size="2"&gt;In SAS:&amp;nbsp;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;JOHN|SMITH|26|1000101|VISIT 1|01DEC2019|RED BLOOD CELLS|10|u/ml|&lt;FONT color="#FF0000"&gt;COMMENTS ABOUT THIS TEST THAT APPEAR ON DIFFERENT LINES&lt;/FONT&gt;|&lt;FONT color="#0000FF"&gt;MORE COMMENTS ON A DIFFERENT LINE THAT BELONG IN A DIFFERENT COLUMN&lt;/FONT&gt;|&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;JOHN|SMITH|26|1000101|VISIT 1|01DEC2019|WHITE BLOOD CELLS|22|u/ml|&lt;FONT color="#FF0000"&gt;COMMENTS ABOUT THIS TEST THAT APPEAR ON DIFFERENT LINES&lt;/FONT&gt;|&lt;FONT color="#0000FF"&gt;MORE COMMENTS ON A DIFFERENT LINE THAT BELONG IN A DIFFERENT COLUMN&lt;/FONT&gt;|&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;Ideally looking to loop, during my input statement to concatenate all&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;FONT color="#FF0000"&gt;A^A&lt;/FONT&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;then&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;FONT color="#0000FF"&gt;A^B&lt;/FONT&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;and insert these into their own columns on the same row.&amp;nbsp; There can be any number of A_A or A_B records or there can be none.&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;Thanks &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Sep 2018 10:18:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-in-multiple-input-lines-into-one-one-observation-and/m-p/496887#M131537</guid>
      <dc:creator>Sha88</dc:creator>
      <dc:date>2018-09-19T10:18:02Z</dc:date>
    </item>
    <item>
      <title>Re: Reading in multiple input lines into one one observation and concatenating</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-in-multiple-input-lines-into-one-one-observation-and/m-p/497201#M131704</link>
      <description>&lt;P&gt;Use the same method (retain and while) and add something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt; if _INFILE_=:'A^A^' then AA=catx(' ',AA,substr(_INFILE_,5));&amp;nbsp;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt; if _INFILE_=:'A^B^' then AB=catx(' ',AB,substr(_INFILE_,5));&lt;/FONT&gt; &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Post your code if you need more help.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Sep 2018 23:42:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-in-multiple-input-lines-into-one-one-observation-and/m-p/497201#M131704</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-09-19T23:42:13Z</dc:date>
    </item>
    <item>
      <title>Re: Reading in multiple input lines into one one observation and concatenating</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-in-multiple-input-lines-into-one-one-observation-and/m-p/497272#M131747</link>
      <description>&lt;P&gt;Hi my code below.&amp;nbsp; &amp;nbsp;There are a few other fields in the A record.&amp;nbsp; &amp;nbsp; The code below still outputs the comments into multiple observations.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;input @1 &lt;FONT color="#0000FF"&gt;RECTYP &lt;/FONT&gt;$ @;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;SELECT&lt;/P&gt;&lt;P&gt;&amp;nbsp;.....&lt;/P&gt;&lt;P&gt;&amp;nbsp;.....&lt;/P&gt;&lt;P&gt;.....&lt;/P&gt;&lt;P&gt;/*Read in Alpha Result Records*/&lt;BR /&gt;when(&lt;FONT color="#0000FF"&gt;RECTYP&lt;/FONT&gt;='A') do;&lt;BR /&gt;input&lt;BR /&gt;&lt;FONT color="#800080"&gt;ATXTTYP&lt;/FONT&gt;: $1. ATEXT: $1000. AALPCD: $15. AOTC: $5. ARTC: $5. ARMKCD: $10.&lt;BR /&gt;;&lt;BR /&gt;if &lt;FONT color="#800080"&gt;ATXTTYP&lt;/FONT&gt;='A' then ATEXT_ST=catx(' ',ATEXT);&lt;BR /&gt;if &lt;FONT color="#800080"&gt;ATXTTYP&lt;/FONT&gt;='B' then ATEXT_ST_B=catx(' ',ATEXT);&lt;BR /&gt;end;&lt;BR /&gt;/*Final Step - Otherwise */&lt;/P&gt;&lt;P&gt;.....&lt;/P&gt;&lt;P&gt;.....&lt;/P&gt;&lt;P&gt;otherwise do;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Sep 2018 08:22:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-in-multiple-input-lines-into-one-one-observation-and/m-p/497272#M131747</guid>
      <dc:creator>Sha88</dc:creator>
      <dc:date>2018-09-20T08:22:55Z</dc:date>
    </item>
    <item>
      <title>Re: Reading in multiple input lines into one one observation and concatenating</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-in-multiple-input-lines-into-one-one-observation-and/m-p/497273#M131748</link>
      <description>You are not using catx correctly. &lt;BR /&gt;</description>
      <pubDate>Thu, 20 Sep 2018 08:26:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-in-multiple-input-lines-into-one-one-observation-and/m-p/497273#M131748</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-09-20T08:26:31Z</dc:date>
    </item>
    <item>
      <title>Re: Reading in multiple input lines into one one observation and concatenating</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-in-multiple-input-lines-into-one-one-observation-and/m-p/497285#M131757</link>
      <description>Figured.</description>
      <pubDate>Thu, 20 Sep 2018 09:07:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-in-multiple-input-lines-into-one-one-observation-and/m-p/497285#M131757</guid>
      <dc:creator>Sha88</dc:creator>
      <dc:date>2018-09-20T09:07:57Z</dc:date>
    </item>
  </channel>
</rss>

