<?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: CSV with hard return in data field in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/CSV-with-hard-return-in-data-field/m-p/574535#M162369</link>
    <description>&lt;P&gt;Very elegant, sharp and innovative. Class act. I didn't know about 'q' modifier. I just read the documentation. The left to right and right to left is still confusing. May have to look at practical example than words to understand. Brilliant indeed.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Btw, would the M modifier take care of trailing blanks too without a T modifier or would the countw count an extra word for a trailing blank without&amp;nbsp; a T modifier? Not perhaps relevant to this thread but just to understand modifiers well&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 18 Jul 2019 12:44:02 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2019-07-18T12:44:02Z</dc:date>
    <item>
      <title>CSV with hard return in data field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CSV-with-hard-return-in-data-field/m-p/574243#M162223</link>
      <description>&lt;P&gt;So I have a .csv file that has what I call hard-returns in it.&amp;nbsp; I'm posting an example below in HAVE.&amp;nbsp; From the example below, I need it to read in 3 records instead of 4.&amp;nbsp; The 2nd record, the Field should read, "Example Test Example Return"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried variations of TERMSTR=CR, SCANOVER, FLOWEVER, etc.&amp;nbsp; I would love any potential help.&amp;nbsp; Thank you!&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;HAVE:&lt;/P&gt;&lt;P&gt;Field1,Field2,Field3&lt;BR /&gt;X,Example Test,100&lt;BR /&gt;X,"Example Test&lt;BR /&gt;Example Return",200&lt;BR /&gt;X,Example Test,300&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;CODE&lt;BR /&gt;DATA NEWFILE;&lt;BR /&gt;INFILE TEMP DLM= "," DSD LRECL=32767 FIRSTOBS=2;&lt;BR /&gt;INPUT&lt;BR /&gt;Field1 :$10.&lt;BR /&gt;Field2 :$10.&lt;BR /&gt;Field3 :$10.&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jul 2019 15:49:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CSV-with-hard-return-in-data-field/m-p/574243#M162223</guid>
      <dc:creator>daadorno</dc:creator>
      <dc:date>2019-07-17T15:49:51Z</dc:date>
    </item>
    <item>
      <title>Re: CSV with hard return in data field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CSV-with-hard-return-in-data-field/m-p/574255#M162228</link>
      <description>&lt;P&gt;Clean it up first. This program will take the data and then remove the hard return and then create a file without it. Then read in that file instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename old 'original.csv';

filename new 'fixed.csv';



data _null_ ;

  if eof then put 'NOTE: Records read=' newn 'Records with missing quotes=' missq ;

  infile old lrecl=10000 end=eof ;

  file new lrecl=10000;

  nq=0;

  do until (mod(nq,2)=0 or eof );

     input;

     newn+1;

     nq = nq + countc(_infile_,'"');

     put _infile_ @;

     if mod(nq,2) then do;

       missq+1;

       put '|' @;

     end;

  end;

  put;

run;&lt;/CODE&gt;&lt;/PRE&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" rel="noopener"&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;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/129347"&gt;@daadorno&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;So I have a .csv file that has what I call hard-returns in it.&amp;nbsp; I'm posting an example below in HAVE.&amp;nbsp; From the example below, I need it to read in 3 records instead of 4.&amp;nbsp; The 2nd record, the Field should read, "Example Test Example Return"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've tried variations of TERMSTR=CR, SCANOVER, FLOWEVER, etc.&amp;nbsp; I would love any potential help.&amp;nbsp; Thank you!&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;HAVE:&lt;/P&gt;
&lt;P&gt;Field1,Field2,Field3&lt;BR /&gt;X,Example Test,100&lt;BR /&gt;X,"Example Test&lt;BR /&gt;Example Return",200&lt;BR /&gt;X,Example Test,300&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;CODE&lt;BR /&gt;DATA NEWFILE;&lt;BR /&gt;INFILE TEMP DLM= "," DSD LRECL=32767 FIRSTOBS=2;&lt;BR /&gt;INPUT&lt;BR /&gt;Field1 :$10.&lt;BR /&gt;Field2 :$10.&lt;BR /&gt;Field3 :$10.&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;RUN;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jul 2019 16:19:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CSV-with-hard-return-in-data-field/m-p/574255#M162228</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-07-17T16:19:29Z</dc:date>
    </item>
    <item>
      <title>Re: CSV with hard return in data field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CSV-with-hard-return-in-data-field/m-p/574260#M162233</link>
      <description>&lt;P&gt;Also see the fifth entry of my footnotes and upvote it.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jul 2019 16:15:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CSV-with-hard-return-in-data-field/m-p/574260#M162233</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-07-17T16:15:51Z</dc:date>
    </item>
    <item>
      <title>Re: CSV with hard return in data field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CSV-with-hard-return-in-data-field/m-p/574297#M162248</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/129347"&gt;@daadorno&lt;/a&gt;&amp;nbsp; &amp;nbsp;Not necessarily recommending, but I wanted some fun&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
	if _n_=1 then
		do;
			dcl hash H ();
			h.definekey  ("_f");
			h.definedata ("field1", "field2");
			h.definedone ();
		end;
	INFILE cards  DSD truncover;
	array field(3)$100;
	if _f=1 then
		do;
			input  _dummy1 :$100. field3 :$100.;
			_rc=h.find();
			field2=catx(' ',field2,_dummy1);
			h.clear();
			call missing(_f);
		end;
	else
		do;
			input field(*);
		      _k=cmiss(of field(*));
		       if _k&amp;gt;0  then  do;
			_f=1;
			_rc=h.add();
			end;
		end;
	if not _f then output;
	retain _f;
	drop _:;
	cards;
X,Example Test,100
X,"Example Test
Example Return",200
X,Example Test,300
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 18 Jul 2019 12:45:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CSV-with-hard-return-in-data-field/m-p/574297#M162248</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-07-18T12:45:00Z</dc:date>
    </item>
    <item>
      <title>Re: CSV with hard return in data field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CSV-with-hard-return-in-data-field/m-p/574532#M162366</link>
      <description>&lt;PRE&gt;data want;
infile cards;
input;
length temp $ 200;
retain temp;
temp=cats(temp,_infile_);
if countw(temp,',','qm')=3 then do;
Field1=dequote(scan(temp,1,',','m'));
Field2=dequote(scan(temp,2,',','m'));
Field3=dequote(scan(temp,3,',','m'));
output;
call missing(temp);
end;
drop temp;
cards;
X,Example Test,100
X,"Example Test
Example Return",200
X,Example Test,300
;&lt;/PRE&gt;</description>
      <pubDate>Thu, 18 Jul 2019 12:23:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CSV-with-hard-return-in-data-field/m-p/574532#M162366</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-07-18T12:23:33Z</dc:date>
    </item>
    <item>
      <title>Re: CSV with hard return in data field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CSV-with-hard-return-in-data-field/m-p/574535#M162369</link>
      <description>&lt;P&gt;Very elegant, sharp and innovative. Class act. I didn't know about 'q' modifier. I just read the documentation. The left to right and right to left is still confusing. May have to look at practical example than words to understand. Brilliant indeed.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Btw, would the M modifier take care of trailing blanks too without a T modifier or would the countw count an extra word for a trailing blank without&amp;nbsp; a T modifier? Not perhaps relevant to this thread but just to understand modifiers well&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2019 12:44:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CSV-with-hard-return-in-data-field/m-p/574535#M162369</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-07-18T12:44:02Z</dc:date>
    </item>
    <item>
      <title>Re: CSV with hard return in data field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CSV-with-hard-return-in-data-field/m-p/574538#M162371</link>
      <description>&lt;P&gt;Nov,&lt;/P&gt;
&lt;P&gt;Ha. Actually I steal this idea from PGStat . Now You could see I took many advantage from all of you .&lt;/P&gt;
&lt;P&gt;It is good for you to stick with sas communities to sharp your sas programming skill .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For your last question:&lt;/P&gt;
&lt;P&gt;I think "&lt;SPAN&gt;would the countw count an extra word for a trailing blank without&amp;nbsp; a T modifier" .You can test it on your own.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2019 12:55:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CSV-with-hard-return-in-data-field/m-p/574538#M162371</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-07-18T12:55:18Z</dc:date>
    </item>
    <item>
      <title>Re: CSV with hard return in data field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CSV-with-hard-return-in-data-field/m-p/574552#M162374</link>
      <description>&lt;P&gt;Everyone thank you for the responses.&amp;nbsp; I am trying them all to see which will work best for me and my team.&amp;nbsp; This is a HUGE help to me and saves me hours of work.&amp;nbsp; Thank you again.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2019 13:16:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CSV-with-hard-return-in-data-field/m-p/574552#M162374</guid>
      <dc:creator>daadorno</dc:creator>
      <dc:date>2019-07-18T13:16:54Z</dc:date>
    </item>
  </channel>
</rss>

