<?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: How to read multiple line data into one observation in infile statement CSV in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-multiple-line-data-into-one-observation-in-infile/m-p/402358#M97690</link>
    <description>&lt;P&gt;Here is an example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile cards truncover;
input x $800.;
length line $ 20000;
retain line;
line=cats(line,x);
if countc(line,'|')=3 then do;output;call missing(line);end;
drop x;
cards;
1|a|ddfd|dsd
2|b|sds
sds|sdsd 
3|c|s
dskdh|asdf
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 09 Oct 2017 13:27:06 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2017-10-09T13:27:06Z</dc:date>
    <item>
      <title>How to read multiple line data into one observation in infile CSV</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-multiple-line-data-into-one-observation-in-infile/m-p/402317#M97670</link>
      <description>&lt;P&gt;Hello expert,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a CSV File with PIPE (|) delimiter.&lt;/P&gt;&lt;P&gt;If you see below screenshot, I need to handle 7th column data which is going to next 4 lines till next &lt;STRONG&gt;delimiter (|).&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;lets assume &amp;nbsp;I have 7th variable name (&lt;STRONG&gt;value)&lt;/STRONG&gt; data is starting from marked dark blue color till next 4 lines.&lt;/P&gt;&lt;P&gt;It is reading wrong, every next line data is appearing to next column. so data is showing wrong.&lt;/P&gt;&lt;P&gt;How to handle this situation, can any body help me on same.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Note - I have already set enough length of column.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"Zeer goed draaiend kantoor waar de produktie de laatste maanden&lt;BR /&gt;fors is gestegen.&lt;BR /&gt;Heeft ondertussen een zilveren statuut , Naviga- Mauretus is in volle expansie en&lt;BR /&gt;zal weldra tot de top drie gaan behoren.&lt;BR /&gt;"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DATA.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/15703iDABC0A2FE56B2D0E/image-size/large?v=v2&amp;amp;px=999" role="button" title="DATA.PNG" alt="DATA.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks in advance .&lt;/P&gt;</description>
      <pubDate>Mon, 09 Oct 2017 11:14:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-multiple-line-data-into-one-observation-in-infile/m-p/402317#M97670</guid>
      <dc:creator>Riteshdell</dc:creator>
      <dc:date>2017-10-09T11:14:12Z</dc:date>
    </item>
    <item>
      <title>How to read multiple line data into one observation in infile statement CSV</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-multiple-line-data-into-one-observation-in-infile/m-p/402319#M97687</link>
      <description>&lt;P&gt;Hello expert,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a CSV File with PIPE (|) delimiter.&lt;/P&gt;&lt;P&gt;If you see below screenshot, I need to handle 7th column data which is going to next 4 lines till next &lt;STRONG&gt;delimiter (|).&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;lets assume &amp;nbsp;I have 7th variable name (&lt;STRONG&gt;value)&lt;/STRONG&gt; data is starting from marked dark blue color till next 4 lines.&lt;/P&gt;&lt;P&gt;It is reading wrong, every next line data is appearing to next column. so data is showing wrong.&lt;/P&gt;&lt;P&gt;How to handle this situation, can any body help me on same.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Note - I have already set enough length of column.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"Zeer goed draaiend kantoor waar de produktie de laatste maanden&lt;BR /&gt;fors is gestegen.&lt;BR /&gt;Heeft ondertussen een zilveren statuut , Naviga- Mauretus is in volle expansie en&lt;BR /&gt;zal weldra tot de top drie gaan behoren.&lt;BR /&gt;"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DATA.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/15703iDABC0A2FE56B2D0E/image-size/large?v=v2&amp;amp;px=999" role="button" title="DATA.PNG" alt="DATA.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks in advance .&lt;/P&gt;</description>
      <pubDate>Mon, 09 Oct 2017 11:15:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-multiple-line-data-into-one-observation-in-infile/m-p/402319#M97687</guid>
      <dc:creator>Riteshdell</dc:creator>
      <dc:date>2017-10-09T11:15:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to read multiple line data into one observation in infile CSV</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-multiple-line-data-into-one-observation-in-infile/m-p/402326#M97673</link>
      <description>&lt;P&gt;Please post textual data into a {i} window, so that&lt;/P&gt;
&lt;P&gt;- formatting is preserved&lt;/P&gt;
&lt;P&gt;- we can copy/paste it to our SAS for testing&lt;/P&gt;
&lt;P&gt;or attach a sample of the file to your post; with this, we can even make sure to see which characters are used for the linebreaks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Oct 2017 11:42:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-multiple-line-data-into-one-observation-in-infile/m-p/402326#M97673</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-10-09T11:42:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to read multiple line data into one observation in infile CSV</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-multiple-line-data-into-one-observation-in-infile/m-p/402328#M97675</link>
      <description>&lt;P&gt;Please post textual data into a {i} window, so that&lt;/P&gt;
&lt;P&gt;- formatting is preserved&lt;/P&gt;
&lt;P&gt;- we can copy/paste it to our SAS for testing&lt;/P&gt;
&lt;P&gt;or attach a sample of the file to your post; with this, we can even make sure to see which characters are used for the linebreaks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Oct 2017 11:45:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-multiple-line-data-into-one-observation-in-infile/m-p/402328#M97675</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-10-09T11:45:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to read multiple line data into one observation in infile statement CSV</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-multiple-line-data-into-one-observation-in-infile/m-p/402339#M97688</link>
      <description>&lt;P&gt;Hello there,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;you could make the approach to read in line by line and then decide, what you want to do with your line.&lt;/P&gt;
&lt;P&gt;Like so:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;&lt;SPAN class="token procnames"&gt;/* dummy code */&lt;BR /&gt;Data&lt;/SPAN&gt; Work&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;Test (drop=help)&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  &lt;SPAN class="token function"&gt;Length&lt;/SPAN&gt; var1 var2 var3 help &lt;SPAN class="token punctuation"&gt;$50&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;BR /&gt;&lt;/SPAN&gt;  Retain var1 var2 var3 help;
  &lt;SPAN class="token keyword"&gt;Input&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  &lt;SPAN class="token keyword"&gt;If&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;countw&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;_infile_&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;"|"&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;3&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;Then&lt;/SPAN&gt; Do&lt;SPAN class="token punctuation"&gt;;&lt;BR /&gt;&lt;/SPAN&gt;    Output; /* output previous line */
    var1 &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;scan&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;_infile_&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;"|"&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
    var2 &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;input&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;scan&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;_infile_&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;2&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;"|"&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;??best&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;BR /&gt;&lt;/SPAN&gt;    help = var2;
    var3 &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;scan&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;_infile_&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;3&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;"|"&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  End&lt;SPAN class="token punctuation"&gt;;&lt;BR /&gt;&lt;/SPAN&gt;  Else Do;&lt;BR /&gt;    var2 = cat(var2, _infile_);&lt;BR /&gt;  End;
&lt;SPAN class="token procnames"&gt;Run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think you get the idea. Read in the line and if you have the desired number of separators, you can read in all variables with scan.&lt;/P&gt;
&lt;P&gt;Now for the lines where you have no "|" , you should take this part and add it to the variable in the previous row.&lt;/P&gt;
&lt;P&gt;Please note that this is just an example code above.&lt;/P&gt;
&lt;P&gt;This leaves some questions, like what to do if another variable gets too long and cut of and you might find a number of separators ,that you do not expect, etc. etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000146292.htm#a000146299" target="_blank"&gt;This&lt;/A&gt;&amp;nbsp;link might also help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It all has to to with checking the line and then deciding what to do with the content &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;Michael&lt;/P&gt;</description>
      <pubDate>Mon, 09 Oct 2017 12:44:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-multiple-line-data-into-one-observation-in-infile/m-p/402339#M97688</guid>
      <dc:creator>mfab</dc:creator>
      <dc:date>2017-10-09T12:44:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to read multiple line data into one observation in infile CSV</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-multiple-line-data-into-one-observation-in-infile/m-p/402354#M97682</link>
      <description>&lt;P&gt;It depends on whether the line breaks in the middle of the lines are stored using the same characters as the file uses to mark the end of line.&amp;nbsp; If you are lucky you can use the TERMSTR= option on the FILENAME or INFILE statement and SAS will be able to tell the difference.&lt;/P&gt;
&lt;P&gt;Otherwise search on this site for solutions to this problem.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/General-SAS-Programming/Carriage-Returns-Need-to-be-removed/td-p/83079" target="_blank"&gt;https://communities.sas.com/t5/General-SAS-Programming/Carriage-Returns-Need-to-be-removed/td-p/83079&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Oct 2017 13:16:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-multiple-line-data-into-one-observation-in-infile/m-p/402354#M97682</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-10-09T13:16:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to read multiple line data into one observation in infile statement CSV</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-multiple-line-data-into-one-observation-in-infile/m-p/402358#M97690</link>
      <description>&lt;P&gt;Here is an example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile cards truncover;
input x $800.;
length line $ 20000;
retain line;
line=cats(line,x);
if countc(line,'|')=3 then do;output;call missing(line);end;
drop x;
cards;
1|a|ddfd|dsd
2|b|sds
sds|sdsd 
3|c|s
dskdh|asdf
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 09 Oct 2017 13:27:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-multiple-line-data-into-one-observation-in-infile/m-p/402358#M97690</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-10-09T13:27:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to read multiple line data into one observation in infile CSV</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-multiple-line-data-into-one-observation-in-infile/m-p/402362#M97691</link>
      <description>&lt;P&gt;I merged two threads; there seems to have been a glitch with the forum SW that created multiple identical posts (including mine and &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;'s).&lt;/P&gt;</description>
      <pubDate>Mon, 09 Oct 2017 13:42:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-multiple-line-data-into-one-observation-in-infile/m-p/402362#M97691</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-10-09T13:42:12Z</dc:date>
    </item>
  </channel>
</rss>

