<?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: Conditional Import based on row value in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Conditional-Import-based-on-row-value/m-p/695208#M212112</link>
    <description>&lt;P&gt;Pseudo code of similar process:&lt;/P&gt;
&lt;PRE&gt;data read;
   infile "&amp;lt;path&amp;gt;\somefile.csv" dlm=',' dsd lrecl=32000;&lt;BR /&gt;   &amp;lt;here should go informat settings for the variables you want&lt;BR /&gt;    you should be able to get them from one your prod IMPORT&lt;BR /&gt;    steps as the proc writes data step code to the log&lt;BR /&gt;    that it generates&amp;gt;
   input @;
   if _infile_ =: "Total" then do;
      &amp;lt;do nothing&amp;gt;&lt;BR /&gt;      input;
   end;
  else do;     &lt;BR /&gt;     input date make count;&lt;BR /&gt;  end;&lt;BR /&gt;;
run;&lt;/PRE&gt;</description>
    <pubDate>Thu, 29 Oct 2020 14:32:13 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2020-10-29T14:32:13Z</dc:date>
    <item>
      <title>Conditional Import based on row value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-Import-based-on-row-value/m-p/695155#M212084</link>
      <description>&lt;P&gt;I have a csv file (that's not really a true csv file) that I'm trying to import and am wondering if there is a way to only import x number of rows until it reads the "total" line. The reason being, my PROC IMPORT is erroring out when it hits the "Total" value, as it's not a date value (which makes sense). The number of rows varies on a weekly basis, so I can't set it based on x number of rows. However, I'm hoping I can set a condition in the import statement to only read in the data until it get's to the "total" line and then ignore anything after the last date. I'll provide an example table below:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Date&lt;/TD&gt;&lt;TD&gt;Make&lt;/TD&gt;&lt;TD&gt;COUNT&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;JAN2019&lt;/TD&gt;&lt;TD&gt;TOYOTA&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;FEB2019&lt;/TD&gt;&lt;TD&gt;FORD&lt;/TD&gt;&lt;TD&gt;17&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;MAR2019&lt;/TD&gt;&lt;TD&gt;CHEVY&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;APR2019&lt;/TD&gt;&lt;TD&gt;MAZDA&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;TOTAL&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;30&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;RANGE JAN2019 TO APR2019&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm not sure if a WHERE statement could work, but am open to any and all suggestions.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Oct 2020 12:49:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-Import-based-on-row-value/m-p/695155#M212084</guid>
      <dc:creator>BlayLay</dc:creator>
      <dc:date>2020-10-29T12:49:00Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Import based on row value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-Import-based-on-row-value/m-p/695170#M212094</link>
      <description>&lt;P&gt;A) do NOT use PROC IMPORT&lt;/P&gt;
&lt;P&gt;B) in the DATA step, first do a "blind read" (&lt;A href="mailto:input@;" target="_blank"&gt;input@;&lt;/A&gt;), then check if the word "TOTAL" appears in _infile_, and if not proceed to read from&amp;nbsp;@1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If that is not clear enough, please post your data step code, and I will show you the necessary modification.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Oct 2020 13:24:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-Import-based-on-row-value/m-p/695170#M212094</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-10-29T13:24:14Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Import based on row value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-Import-based-on-row-value/m-p/695171#M212095</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/349857"&gt;@BlayLay&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instead of using proc import, you could try using a data step so that you could examine the text in your input file by reading the first column as character and if it is a date then apply an informat to convert it to a SAS date.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are some examples of reading a csv in:&lt;BR /&gt;&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.5&amp;amp;docsetId=lestmtsref&amp;amp;docsetTarget=n1rill4udj0tfun1fvce3j401plo.htm&amp;amp;locale=en"&gt;https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.5&amp;amp;docsetId=lestmtsref&amp;amp;docsetTarget=n1rill4udj0tfun1fvce3j401plo.htm&amp;amp;locale=en&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards,&lt;/P&gt;
&lt;P&gt;Amir.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Oct 2020 13:26:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-Import-based-on-row-value/m-p/695171#M212095</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2020-10-29T13:26:48Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Import based on row value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-Import-based-on-row-value/m-p/695208#M212112</link>
      <description>&lt;P&gt;Pseudo code of similar process:&lt;/P&gt;
&lt;PRE&gt;data read;
   infile "&amp;lt;path&amp;gt;\somefile.csv" dlm=',' dsd lrecl=32000;&lt;BR /&gt;   &amp;lt;here should go informat settings for the variables you want&lt;BR /&gt;    you should be able to get them from one your prod IMPORT&lt;BR /&gt;    steps as the proc writes data step code to the log&lt;BR /&gt;    that it generates&amp;gt;
   input @;
   if _infile_ =: "Total" then do;
      &amp;lt;do nothing&amp;gt;&lt;BR /&gt;      input;
   end;
  else do;     &lt;BR /&gt;     input date make count;&lt;BR /&gt;  end;&lt;BR /&gt;;
run;&lt;/PRE&gt;</description>
      <pubDate>Thu, 29 Oct 2020 14:32:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-Import-based-on-row-value/m-p/695208#M212112</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-10-29T14:32:13Z</dc:date>
    </item>
  </channel>
</rss>

