<?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: SAS CSV File error and file names in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-CSV-File-error-and-file-names/m-p/465857#M118831</link>
    <description>&lt;P&gt;Why a macro variable?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think you need to explain more. There are ways to handle data with multiple headers.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-do-I-write-a-macro-to-import-multiple-text-files-that-have/ta-p/223627" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-do-I-write-a-macro-to-import-multiple-text-files-that-have/ta-p/223627&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 29 May 2018 22:39:09 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-05-29T22:39:09Z</dc:date>
    <item>
      <title>SAS CSV File error and file names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-CSV-File-error-and-file-names/m-p/465844#M118826</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; i am reading multiple SAS Files assuming headers are on first row. i use firstobs=2 and there are no issues with files having headers on first row. but when headers span on row 2 and/or row 3 then i get error in log saying invalid data and has _error_= 1 and _n_=1 variable which is expected&amp;nbsp;BUT is there a way to capture csv files names and count of those csv files&amp;nbsp; IN macro variable when this error is triggered. i want to display custom message something like&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"There are 2 files with incorrect headers and names of files are A.csv, B.csv. Please update file and rerun."&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;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 May 2018 21:30:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-CSV-File-error-and-file-names/m-p/465844#M118826</guid>
      <dc:creator>sasuser101</dc:creator>
      <dc:date>2018-05-29T21:30:45Z</dc:date>
    </item>
    <item>
      <title>Re: SAS CSV File error and file names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-CSV-File-error-and-file-names/m-p/465848#M118828</link>
      <description>&lt;P&gt;Probably. Please explain in more detail what exactly you are currently doing.&amp;nbsp; &amp;nbsp;preferable with code that we can run to test.&lt;/P&gt;</description>
      <pubDate>Tue, 29 May 2018 21:52:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-CSV-File-error-and-file-names/m-p/465848#M118828</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-05-29T21:52:20Z</dc:date>
    </item>
    <item>
      <title>Re: SAS CSV File error and file names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-CSV-File-error-and-file-names/m-p/465850#M118829</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Assuming&lt;/STRONG&gt;, since no code was included, that your FIRSTOBS=2 is on a INFILE statement you might try adding a FILENAME= option to the infile statement which would add a temporary variable similar to _n_ you could reference&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; infile "path/name" dlm=',' firstobs=2 filename=myinfile;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; input &amp;lt;varlist&amp;gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; if _error_=1 and _n_=1 then call symputx('possbadfile',myinfile);&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It would be up to you to provide additional logic for using that &amp;amp;possbadfile macro variable to make that message string.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe. guessing because code would give a much better starting point.&lt;/P&gt;</description>
      <pubDate>Tue, 29 May 2018 22:16:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-CSV-File-error-and-file-names/m-p/465850#M118829</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-05-29T22:16:07Z</dc:date>
    </item>
    <item>
      <title>Re: SAS CSV File error and file names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-CSV-File-error-and-file-names/m-p/465857#M118831</link>
      <description>&lt;P&gt;Why a macro variable?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think you need to explain more. There are ways to handle data with multiple headers.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-do-I-write-a-macro-to-import-multiple-text-files-that-have/ta-p/223627" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-do-I-write-a-macro-to-import-multiple-text-files-that-have/ta-p/223627&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 May 2018 22:39:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-CSV-File-error-and-file-names/m-p/465857#M118831</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-05-29T22:39:09Z</dc:date>
    </item>
  </channel>
</rss>

