<?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 events that happen after the 15th of each month in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Deleting-events-that-happen-after-the-15th-of-each-month/m-p/864091#M341267</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/43822"&gt;@Wolverine&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;That is a simple and elegant solution!&amp;nbsp; Also informative, because I didn't know about the functions to extract information from date variables.&amp;nbsp; Thanks!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You may find this helpful: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/ta-p/424354" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/ta-p/424354&lt;/A&gt; has a PDF with much information about dates.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also the many Formats supplied by SAS and that you can make custom formats for date, time and datetime values using Proc Format is helpful as the groups created by formats are usable in reporting and analysis procs and sometimes graphing (kind of picky there).&lt;/P&gt;
&lt;P&gt;The INTNX and INTCK functions for incrementing or determining intervals also allow some shifts and offsets to get many common intervals of interest for manipulating dates.&lt;/P&gt;</description>
    <pubDate>Tue, 14 Mar 2023 15:29:57 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2023-03-14T15:29:57Z</dc:date>
    <item>
      <title>Deleting events that happen after the 15th of each month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-events-that-happen-after-the-15th-of-each-month/m-p/863859#M341186</link>
      <description>&lt;P&gt;I have a series of records with dates that appear like "05/23/2022" in the data.&amp;nbsp; Proc Contents indicates the following:&lt;/P&gt;
&lt;P&gt;birth_infantdob Num 8 MMDDYY.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My plan was to extract the middle 2 digits (23 in the example) and use a simple IF/THEN:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA want; SET HAVE;
day_of_month_birth = SUBSTR(birth_infantdob,3,2);		
IF day_of_month_birth &amp;gt; 15 THEN delete;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But since the date is numeric, I have to convert it to text before I can use SUBSTR.&amp;nbsp; But every time I try to convert it, &lt;CODE class=" language-sas"&gt;day_of_month_birth &lt;/CODE&gt; is either blank, has a dot (ie, a numeric blank), or equals the number of days since Jan 1 1960.&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Mar 2023 18:28:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-events-that-happen-after-the-15th-of-each-month/m-p/863859#M341186</guid>
      <dc:creator>Wolverine</dc:creator>
      <dc:date>2023-03-13T18:28:59Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting events that happen after the 15th of each month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-events-that-happen-after-the-15th-of-each-month/m-p/863885#M341189</link>
      <description>&lt;P&gt;Your variable, as indicated by the Format, is a SAS date value. Which means you have access to many functions to extract values such as day of month ,the Day function&lt;/P&gt;
&lt;P&gt;So what you request, one way:&lt;/P&gt;
&lt;PRE&gt;DATA want; 
   SET HAVE;
   where day(birth_infantdob) le 15;
RUN;&lt;/PRE&gt;
&lt;P&gt;WHERE, which works with values in the source data set, executes a bit faster and keeps values where the comparison is true.&lt;/P&gt;
&lt;P&gt;You can also use&lt;/P&gt;
&lt;PRE&gt;if day(birth_infantdob) &amp;gt; 15 then delete;&lt;/PRE&gt;
&lt;P&gt;if you prefer.&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/43822"&gt;@Wolverine&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have a series of records with dates that appear like "05/23/2022" in the data.&amp;nbsp; Proc Contents indicates the following:&lt;/P&gt;
&lt;P&gt;birth_infantdob Num 8 MMDDYY.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My plan was to extract the middle 2 digits (23 in the example) and use a simple IF/THEN:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA want; SET HAVE;
day_of_month_birth = SUBSTR(birth_infantdob,3,2);		
IF day_of_month_birth &amp;gt; 15 THEN delete;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But since the date is numeric, I have to convert it to text before I can use SUBSTR.&amp;nbsp; But every time I try to convert it, &lt;CODE class=" language-sas"&gt;day_of_month_birth &lt;/CODE&gt; is either blank, has a dot (ie, a numeric blank), or equals the number of days since Jan 1 1960.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Mar 2023 19:08:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-events-that-happen-after-the-15th-of-each-month/m-p/863885#M341189</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-03-13T19:08:13Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting events that happen after the 15th of each month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-events-that-happen-after-the-15th-of-each-month/m-p/864082#M341262</link>
      <description>&lt;P&gt;That is a simple and elegant solution!&amp;nbsp; Also informative, because I didn't know about the functions to extract information from date variables.&amp;nbsp; Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 14 Mar 2023 15:01:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-events-that-happen-after-the-15th-of-each-month/m-p/864082#M341262</guid>
      <dc:creator>Wolverine</dc:creator>
      <dc:date>2023-03-14T15:01:20Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting events that happen after the 15th of each month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-events-that-happen-after-the-15th-of-each-month/m-p/864091#M341267</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/43822"&gt;@Wolverine&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;That is a simple and elegant solution!&amp;nbsp; Also informative, because I didn't know about the functions to extract information from date variables.&amp;nbsp; Thanks!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You may find this helpful: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/ta-p/424354" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/ta-p/424354&lt;/A&gt; has a PDF with much information about dates.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also the many Formats supplied by SAS and that you can make custom formats for date, time and datetime values using Proc Format is helpful as the groups created by formats are usable in reporting and analysis procs and sometimes graphing (kind of picky there).&lt;/P&gt;
&lt;P&gt;The INTNX and INTCK functions for incrementing or determining intervals also allow some shifts and offsets to get many common intervals of interest for manipulating dates.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Mar 2023 15:29:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-events-that-happen-after-the-15th-of-each-month/m-p/864091#M341267</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-03-14T15:29:57Z</dc:date>
    </item>
  </channel>
</rss>

