<?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: Count number of fields in Flat file in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Count-number-of-fields-in-Flat-file/m-p/812866#M320745</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/176322"&gt;@PRAVIN_JAIN&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have a flat file to read in SAS with delimiter&amp;nbsp;'¬'. Before reading in SAS, i want to check no of columns in each row using unix command however it gives incorrect result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Command used - awk -F'¬' '{print NF}' in_file.txt | uniq&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please suggest.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;For Unix/Linux these things are really simple to Google. There is so much out there. Like &lt;A href="https://stackoverflow.com/questions/8629410/count-occurrences-of-character-per-line-field-on-unix" target="_self"&gt;here&lt;/A&gt; for example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;WHY do you want to do this? If it's just so that some lines have less columns (like when there is no data for the last few columns) then just use the truncover option in the infile statement and SAS will handle this nicely.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could also use SAS for counting the characters. Just a SAS datastep with an infile and input statement and then the countc() function&lt;/P&gt;</description>
    <pubDate>Thu, 12 May 2022 06:37:59 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2022-05-12T06:37:59Z</dc:date>
    <item>
      <title>Count number of fields in Flat file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-number-of-fields-in-Flat-file/m-p/812856#M320742</link>
      <description>&lt;P&gt;I have a flat file to read in SAS with delimiter&amp;nbsp;'¬'. Before reading in SAS, i want to check no of columns in each row using unix command however it gives incorrect result.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Command used - awk -F'¬' '{print NF}' in_file.txt | uniq&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please suggest.&lt;/P&gt;</description>
      <pubDate>Thu, 12 May 2022 04:03:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-number-of-fields-in-Flat-file/m-p/812856#M320742</guid>
      <dc:creator>PRAVIN_JAIN</dc:creator>
      <dc:date>2022-05-12T04:03:13Z</dc:date>
    </item>
    <item>
      <title>Re: Count number of fields in Flat file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-number-of-fields-in-Flat-file/m-p/812866#M320745</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/176322"&gt;@PRAVIN_JAIN&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have a flat file to read in SAS with delimiter&amp;nbsp;'¬'. Before reading in SAS, i want to check no of columns in each row using unix command however it gives incorrect result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Command used - awk -F'¬' '{print NF}' in_file.txt | uniq&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please suggest.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;For Unix/Linux these things are really simple to Google. There is so much out there. Like &lt;A href="https://stackoverflow.com/questions/8629410/count-occurrences-of-character-per-line-field-on-unix" target="_self"&gt;here&lt;/A&gt; for example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;WHY do you want to do this? If it's just so that some lines have less columns (like when there is no data for the last few columns) then just use the truncover option in the infile statement and SAS will handle this nicely.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could also use SAS for counting the characters. Just a SAS datastep with an infile and input statement and then the countc() function&lt;/P&gt;</description>
      <pubDate>Thu, 12 May 2022 06:37:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-number-of-fields-in-Flat-file/m-p/812866#M320745</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2022-05-12T06:37:59Z</dc:date>
    </item>
  </channel>
</rss>

