<?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: checking number of columns in a csv file in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/checking-number-of-columns-in-a-csv-file/m-p/899914#M355656</link>
    <description>&lt;P&gt;Old habits die hard &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Since I mainly used INFILE in my professional work for fixed-length files (RECFM=F) where thde default LRECL is 256, I tend to always set it.&lt;/P&gt;
&lt;P&gt;But for variable-length files, the default is 32767, so no separate LRECL is needed.&lt;/P&gt;</description>
    <pubDate>Wed, 25 Oct 2023 10:02:17 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2023-10-25T10:02:17Z</dc:date>
    <item>
      <title>checking number of columns in a csv file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/checking-number-of-columns-in-a-csv-file/m-p/899901#M355650</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Is there a code to know the number of columns in a csv file?&lt;/P&gt;
&lt;P&gt;We are using a program that inputs csv files. There are sometimes errors in the input files, were they have fewer columns then they need to have. I am looking for a way to check the number of columns. If less/more then required, I will write a code to send a warning (that is not a problem). Thank you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2023 09:21:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/checking-number-of-columns-in-a-csv-file/m-p/899901#M355650</guid>
      <dc:creator>Taliah</dc:creator>
      <dc:date>2023-10-25T09:21:46Z</dc:date>
    </item>
    <item>
      <title>Re: checking number of columns in a csv file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/checking-number-of-columns-in-a-csv-file/m-p/899902#M355651</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
infile "path_to_your_file" lrecl=1000; /* set lrecl to sufficient value */
input;
call symputx("no_of_columns",countw(_infile_,","));
stop;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The macro variable will contain the number of column names found in the header line.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2023 09:26:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/checking-number-of-columns-in-a-csv-file/m-p/899902#M355651</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-10-25T09:26:46Z</dc:date>
    </item>
    <item>
      <title>Re: checking number of columns in a csv file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/checking-number-of-columns-in-a-csv-file/m-p/899903#M355652</link>
      <description>&lt;P&gt;great, Thank you!&lt;/P&gt;
&lt;P&gt;I see the code you sent works with and without lrecl. Do you know if I can leave that out?&lt;/P&gt;
&lt;P&gt;in the input code I use:&lt;/P&gt;
&lt;P&gt;data test;&lt;/P&gt;
&lt;P&gt;infile "[path and file] "&amp;nbsp; dlm=","&amp;nbsp; firstobs=1;&lt;/P&gt;
&lt;P&gt;length a b c ...8;&lt;/P&gt;
&lt;P&gt;input a b c...;&lt;/P&gt;
&lt;P&gt;format a b c ... best12.;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the code you sent to check number of columns works fine the way you sent it and without lrecl&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2023 09:40:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/checking-number-of-columns-in-a-csv-file/m-p/899903#M355652</guid>
      <dc:creator>Taliah</dc:creator>
      <dc:date>2023-10-25T09:40:37Z</dc:date>
    </item>
    <item>
      <title>Re: checking number of columns in a csv file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/checking-number-of-columns-in-a-csv-file/m-p/899914#M355656</link>
      <description>&lt;P&gt;Old habits die hard &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Since I mainly used INFILE in my professional work for fixed-length files (RECFM=F) where thde default LRECL is 256, I tend to always set it.&lt;/P&gt;
&lt;P&gt;But for variable-length files, the default is 32767, so no separate LRECL is needed.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2023 10:02:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/checking-number-of-columns-in-a-csv-file/m-p/899914#M355656</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-10-25T10:02:17Z</dc:date>
    </item>
  </channel>
</rss>

