<?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 a csv file with records length more than 33,000 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Reading-a-csv-file-with-records-length-more-than-33-000/m-p/678417#M204748</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp; We get the following error.&lt;/P&gt;
&lt;PRE&gt;ERROR: The LRECL / LINESIZE for infile '"\\eDiary_small.csv"' exceeds the 
       maximum allowable length for an _INFILE_ or _INFILE_= variable (32,767). The DATA STEP will not be executed.&lt;/PRE&gt;</description>
    <pubDate>Fri, 21 Aug 2020 11:55:20 GMT</pubDate>
    <dc:creator>Satish_Parida</dc:creator>
    <dc:date>2020-08-21T11:55:20Z</dc:date>
    <item>
      <title>Reading a csv file with records length more than 33,000</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-a-csv-file-with-records-length-more-than-33-000/m-p/678395#M204734</link>
      <description>&lt;P&gt;Hi Experts,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a table where I have 3 variables of length&amp;nbsp;32,767 each.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am reading data from a CSV file. Some times we expect these fields to contain 32,767 characters.&amp;nbsp;&lt;BR /&gt;In that case the CSV file length goes above 33,000.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So in this case SAS truncates the data or it does not behave as it is supposed to.&lt;BR /&gt;1. Can we increase the logical record length to handle more data in input buffer?&lt;BR /&gt;2. Is there more elegant solution to this?&lt;BR /&gt;&lt;BR /&gt;Code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*replace NewLines,Line Feed,Line Break with space if any and create a temp file;&lt;BR /&gt;filename workfile "\\vendorFile\tmp.csv";
data _null_ ;
if eof then put 'NOTE: Records read=' newn 'Records with missing quotes=' missq ;
	infile "\\eDiary_small.csv" lrecl=32767 end=eof ;
file workfile ;
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;BR /&gt;*Read the File to create SAS dataset;
data sas_vout.eDiary;
infile workfile dlm="," dsd firstobs=2 lrecl=32767;
input PATIENT_S_DUE_TIME_C:$24. PATIENT_S_TIMEZONE__C:$255. PATIENT_ID_SUBJECT_ID__C:$255. 
VTD2_STUDY_NICKNAME__C:$255. VTR4_CROSS_REFERENCE_SUBJECT_ID_:$100. ANSWER_ID:$18. DIARY_ID:$18. NAME:$80. VTD1_SURVEY__C:$18. 
VTD1_ANSWER__C:$32767. VTR2_ENGLISH_ANSWER__C:$32767. VTR2_QUESTION_CONTENT__C:$32767. CREATEDDATE:$24. 
VTD1_COMPLETION_TIME__C:$24. VTD1_DATE_AVAILABLE__C:$24. VTD1_DUE_DATE__C:$24. VTD2_PATIENT_S_DUE_TIME__C:$24. 
VTD2_PATIENT_S_NUMERIC_TIMEZONE_:$255. VTD1_STATUS__C:$255. VTR2_DOC_LANGUAGE__C:$5. VTD1_REMINDER_DUE_DATE__C:$24. 
VTD1_REMINDER_WINDOW__C:$18. VTD1_NUMBER_OF_ANSWERS__C:$18. VTD1_NUMBER_OF_SCORED_ANSWERS__C:$18. VTR2_REVIEWER_USER__C:$16. 
VTR2_NUMBER_OF_ANSWERED_ANSWERS_:$18. VTR2_TOTAL_SCORE__C:$18. VTR4_PERCENTAGE_COMPLETED__C:$3.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Test Records are Huge, so I have attached it. File size less that 200kb&lt;BR /&gt;&lt;BR /&gt;Thank you in advance.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Aug 2020 10:06:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-a-csv-file-with-records-length-more-than-33-000/m-p/678395#M204734</guid>
      <dc:creator>Satish_Parida</dc:creator>
      <dc:date>2020-08-21T10:06:13Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a csv file with records length more than 33,000</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-a-csv-file-with-records-length-more-than-33-000/m-p/678416#M204747</link>
      <description>You could set it very big :&lt;BR /&gt;&lt;BR /&gt;lrecl=100000000</description>
      <pubDate>Fri, 21 Aug 2020 11:49:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-a-csv-file-with-records-length-more-than-33-000/m-p/678416#M204747</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-08-21T11:49:16Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a csv file with records length more than 33,000</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-a-csv-file-with-records-length-more-than-33-000/m-p/678417#M204748</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp; We get the following error.&lt;/P&gt;
&lt;PRE&gt;ERROR: The LRECL / LINESIZE for infile '"\\eDiary_small.csv"' exceeds the 
       maximum allowable length for an _INFILE_ or _INFILE_= variable (32,767). The DATA STEP will not be executed.&lt;/PRE&gt;</description>
      <pubDate>Fri, 21 Aug 2020 11:55:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-a-csv-file-with-records-length-more-than-33-000/m-p/678417#M204748</guid>
      <dc:creator>Satish_Parida</dc:creator>
      <dc:date>2020-08-21T11:55:20Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a csv file with records length more than 33,000</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-a-csv-file-with-records-length-more-than-33-000/m-p/678421#M204750</link>
      <description>Do not use _infile_ ,Try LIST or FORMATTED input method .</description>
      <pubDate>Fri, 21 Aug 2020 12:15:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-a-csv-file-with-records-length-more-than-33-000/m-p/678421#M204750</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-08-21T12:15:12Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a csv file with records length more than 33,000</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-a-csv-file-with-records-length-more-than-33-000/m-p/678466#M204777</link>
      <description>&lt;P&gt;A single variable cannot be longer than the 32k limit either, ie the _infile_ cannot be used.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's likely erroring out in your first data step but not the second.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What are you fixing with the first step? It looks like you read it in and write it back out, and then read it back in again. Maybe there's a way to avoid that?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Aug 2020 14:57:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-a-csv-file-with-records-length-more-than-33-000/m-p/678466#M204777</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-08-21T14:57:33Z</dc:date>
    </item>
    <item>
      <title>Re: Reading a csv file with records length more than 33,000</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-a-csv-file-with-records-length-more-than-33-000/m-p/678472#M204781</link>
      <description>&lt;P&gt;I see some things that make me question how well your source file may be documented. You have a variable PATIENT_S_TIMEZONE__C as $255. I don't think I have ever seen a timezone indicator that ran more than 6 characters. Are getting text like "Grenwich Mean Time" or something for that? There are several of the variables with $255 that I wonder if the values actually come close to that length.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Plus variables whose name include such things a "number of answers" and are character???&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You are reading time and date values into character variables as well. I normally try to make sure these are actually SAS time, date or datetime variables as appropriate as early as practical with appropriate formats.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your use of _infile_ was to strip out newline/linefeed characters in the middle of long text strings, such as your "answer" variables, you might go the source that collects the data and see if those can be addressed when exported or the CSV file is created.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Aug 2020 15:05:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-a-csv-file-with-records-length-more-than-33-000/m-p/678472#M204781</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-08-21T15:05:29Z</dc:date>
    </item>
  </channel>
</rss>

