<?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: Delete a date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Delete-a-date/m-p/337458#M272550</link>
    <description>&lt;P&gt;This will probably work better:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data new;
   set have;
   if date eq "11FEB2017"d then delete;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In SAS you can specify a date constant by a date9 formatted string between quotes and a 'd' behind it. Look up the docs for date, time and datetime literals.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps,&lt;/P&gt;
&lt;P&gt;- Jan.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 02 Mar 2017 17:07:11 GMT</pubDate>
    <dc:creator>jklaverstijn</dc:creator>
    <dc:date>2017-03-02T17:07:11Z</dc:date>
    <item>
      <title>Delete a date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-a-date/m-p/337452#M272549</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm trying to delete the date from my dataset and I used this statement to delete but it is not working.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data new;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;if date eq 2/11/17 then delete;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It is not working, I have the same format for date in my dataset and it is a numeric var.&lt;/P&gt;&lt;P&gt;I need to delete 2/11/17 and 2/12/17, I tried with 2/11/17 first and is nto working.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;M&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2017 16:58:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-a-date/m-p/337452#M272549</guid>
      <dc:creator>Malathi13</dc:creator>
      <dc:date>2017-03-02T16:58:14Z</dc:date>
    </item>
    <item>
      <title>Re: Delete a date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-a-date/m-p/337458#M272550</link>
      <description>&lt;P&gt;This will probably work better:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data new;
   set have;
   if date eq "11FEB2017"d then delete;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In SAS you can specify a date constant by a date9 formatted string between quotes and a 'd' behind it. Look up the docs for date, time and datetime literals.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps,&lt;/P&gt;
&lt;P&gt;- Jan.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2017 17:07:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-a-date/m-p/337458#M272550</guid>
      <dc:creator>jklaverstijn</dc:creator>
      <dc:date>2017-03-02T17:07:11Z</dc:date>
    </item>
    <item>
      <title>Re: Delete a date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-a-date/m-p/337460#M272551</link>
      <description>&lt;P&gt;Hi Jan,&lt;/P&gt;&lt;P&gt;I tried that, I don't see any errors but I see the dates still exist in the dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;M&lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2017 17:11:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-a-date/m-p/337460#M272551</guid>
      <dc:creator>Malathi13</dc:creator>
      <dc:date>2017-03-02T17:11:08Z</dc:date>
    </item>
    <item>
      <title>Re: Delete a date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-a-date/m-p/337462#M272552</link>
      <description>&lt;P&gt;Then it would help if you can show a sample of your data and the output of proc contents of the dataset you're working with. Maybe what you think to be a date is in fact not.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;- Jan.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2017 17:13:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-a-date/m-p/337462#M272552</guid>
      <dc:creator>jklaverstijn</dc:creator>
      <dc:date>2017-03-02T17:13:22Z</dc:date>
    </item>
    <item>
      <title>Re: Delete a date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-a-date/m-p/337525#M272553</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; If your date is internally stored as a numeric variable which represents the number of days since January 1, 1960 then the code shown in the screen shot should work. The DELETE statement, does work correctly, as illustrated by this sample program with 3 rows of "fake" data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/7533i3D2610992084F51C/image-size/original?v=1.0&amp;amp;px=-1" alt="delete_works.png" title="delete_works.png" border="0" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; If your program does not work then there are some possibilities to investigate, as suggested:&lt;/P&gt;
&lt;P&gt;1) if your variable is a numeric variable which represents the number of days since Jan 1, 1960, then you need to use a date constant in the IF statement;&lt;/P&gt;
&lt;P&gt;2) If your variable is a character string that just looks like a date, but is not a number, then you need to either convert your character string to a numeric variable (using an INPUT function); use a character comparison;&lt;/P&gt;
&lt;P&gt;3) if your variable is really a datetime value (like 11feb2017:01:15:30) then you need to use a different function to extract only the date portion from the datetime value;&lt;/P&gt;
&lt;P&gt;4) if your variable is a number, like 20170211 or 02112017, then you will need to use different functions to turn the "plain" number into a SAS date value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Hope this illustrates that the DELETE statement does work, when your IF statement is valid.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;cynthia&lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2017 19:38:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-a-date/m-p/337525#M272553</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2017-03-02T19:38:28Z</dc:date>
    </item>
  </channel>
</rss>

