<?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: deleting record based on text field and date selection in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/deleting-record-based-on-text-field-and-date-selection/m-p/360135#M84727</link>
    <description>&lt;P&gt;You mentioned that status is a 10 character length field. Are you possibly wanting to delete a record if its status field contains an "A"? If so, you could use:&lt;/P&gt;
&lt;PRE&gt;data db.table;
  informat status $10.;
  length status $10;
  input status;
  cards;
A
BC
 A
ABC
BCD
;

data temp_weekly_data;
  set DB.TABLE (where = (&amp;amp;date1 &amp;lt;= date_my &amp;lt; &amp;amp;date2 ) );
  if find(status,"A") and datepart(date_my) &amp;lt; today() then delete;
run;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 19 May 2017 21:53:37 GMT</pubDate>
    <dc:creator>art297</dc:creator>
    <dc:date>2017-05-19T21:53:37Z</dc:date>
    <item>
      <title>deleting record based on text field and date selection</title>
      <link>https://communities.sas.com/t5/SAS-Programming/deleting-record-based-on-text-field-and-date-selection/m-p/360105#M84720</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to delete records from table&amp;nbsp;&lt;SPAN&gt;temp_weekly_data where the date is less than today and status is equal to&amp;nbsp;A&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;following code is deleting records where&amp;nbsp;the date is less than today(), ignoring if the staus value&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;data temp_weekly_data;&lt;BR /&gt; set DB.TABLE(where = (&amp;amp;date1 &amp;lt;= date_my&amp;nbsp;&amp;lt; &amp;amp;date2&amp;nbsp;) );&lt;/P&gt;
&lt;P&gt;if status&amp;nbsp;in ("A") and datepart(&lt;SPAN&gt;date_my&lt;/SPAN&gt;) &amp;lt; today() then delete;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;staus field is of type Text, 10 character length&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance&lt;/P&gt;</description>
      <pubDate>Fri, 19 May 2017 20:12:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/deleting-record-based-on-text-field-and-date-selection/m-p/360105#M84720</guid>
      <dc:creator>tparvaiz</dc:creator>
      <dc:date>2017-05-19T20:12:40Z</dc:date>
    </item>
    <item>
      <title>Re: deleting record based on text field and date selection</title>
      <link>https://communities.sas.com/t5/SAS-Programming/deleting-record-based-on-text-field-and-date-selection/m-p/360110#M84723</link>
      <description>&lt;P&gt;Your code should work fine only in case status is always in capital letter.&lt;/P&gt;
&lt;P&gt;Are &amp;amp;date1 and &amp;amp;date2 given as datetime or date only ?&lt;/P&gt;
&lt;P&gt;Are your where consistent with the IF statement ? (either date variable or datetime variable)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may test:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data temp_weekly_data;
   set DB.TABLE(where = (&amp;amp;date1 &amp;lt;= date_my &amp;lt; &amp;amp;date2 ) );
       if upcase(status) = "A"  
         and &lt;U&gt;&lt;STRONG&gt;datepart&lt;/STRONG&gt;&lt;/U&gt;(date_my) &amp;lt; today() then delete;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 19 May 2017 20:28:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/deleting-record-based-on-text-field-and-date-selection/m-p/360110#M84723</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-05-19T20:28:59Z</dc:date>
    </item>
    <item>
      <title>Re: deleting record based on text field and date selection</title>
      <link>https://communities.sas.com/t5/SAS-Programming/deleting-record-based-on-text-field-and-date-selection/m-p/360135#M84727</link>
      <description>&lt;P&gt;You mentioned that status is a 10 character length field. Are you possibly wanting to delete a record if its status field contains an "A"? If so, you could use:&lt;/P&gt;
&lt;PRE&gt;data db.table;
  informat status $10.;
  length status $10;
  input status;
  cards;
A
BC
 A
ABC
BCD
;

data temp_weekly_data;
  set DB.TABLE (where = (&amp;amp;date1 &amp;lt;= date_my &amp;lt; &amp;amp;date2 ) );
  if find(status,"A") and datepart(date_my) &amp;lt; today() then delete;
run;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 May 2017 21:53:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/deleting-record-based-on-text-field-and-date-selection/m-p/360135#M84727</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-05-19T21:53:37Z</dc:date>
    </item>
  </channel>
</rss>

