<?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: Removing Year from a date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Removing-Year-from-a-date/m-p/397810#M278339</link>
    <description>&lt;P&gt;You could extract day and month using day and month functions. Do you have a sample input and wanted output for the community to know your requirement&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You could also use a format like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data w;&lt;BR /&gt;date=today();&lt;BR /&gt;&lt;STRONG&gt;new_date&lt;/STRONG&gt;=put(date,&lt;STRONG&gt;date5.&lt;/STRONG&gt;);&lt;BR /&gt;format date date5.;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc contents;run;&lt;/P&gt;</description>
    <pubDate>Thu, 21 Sep 2017 15:57:39 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2017-09-21T15:57:39Z</dc:date>
    <item>
      <title>Removing Year from a date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-Year-from-a-date/m-p/397809#M278338</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to create a campaign, using CI, based on a customers date of birth. To do so i need to remove the year, as this is irrelvant, and focus purely on the day and month.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there are function available to do this?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Ben&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2017 15:50:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-Year-from-a-date/m-p/397809#M278338</guid>
      <dc:creator>CRM_Ben</dc:creator>
      <dc:date>2017-09-21T15:50:52Z</dc:date>
    </item>
    <item>
      <title>Re: Removing Year from a date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-Year-from-a-date/m-p/397810#M278339</link>
      <description>&lt;P&gt;You could extract day and month using day and month functions. Do you have a sample input and wanted output for the community to know your requirement&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You could also use a format like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data w;&lt;BR /&gt;date=today();&lt;BR /&gt;&lt;STRONG&gt;new_date&lt;/STRONG&gt;=put(date,&lt;STRONG&gt;date5.&lt;/STRONG&gt;);&lt;BR /&gt;format date date5.;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc contents;run;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2017 15:57:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-Year-from-a-date/m-p/397810#M278339</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2017-09-21T15:57:39Z</dc:date>
    </item>
    <item>
      <title>Re: Removing Year from a date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-Year-from-a-date/m-p/397812#M278340</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The format is curently DATE9. but i'm trying to create a calculated item with, for example, 01JAN.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This will allow me to select all birthdays in on a certain date without having to condsider all the possible years they could have been born in.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Ben&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2017 15:58:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-Year-from-a-date/m-p/397812#M278340</guid>
      <dc:creator>CRM_Ben</dc:creator>
      <dc:date>2017-09-21T15:58:56Z</dc:date>
    </item>
    <item>
      <title>Re: Removing Year from a date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-Year-from-a-date/m-p/397813#M278341</link>
      <description>Thanks, i'll try this&lt;BR /&gt;</description>
      <pubDate>Thu, 21 Sep 2017 15:59:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-Year-from-a-date/m-p/397813#M278341</guid>
      <dc:creator>CRM_Ben</dc:creator>
      <dc:date>2017-09-21T15:59:17Z</dc:date>
    </item>
    <item>
      <title>Re: Removing Year from a date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-Year-from-a-date/m-p/397815#M278342</link>
      <description>&lt;P&gt;90% of the time SAS dates are more efficient, this may be one that it's not.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't know how you're filtering/grouping but does applying a different format help at all?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This would filter all people born on October 5th.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where day(birth_date)=5 and month(birth_date)=10;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can use the ddmmyy4. format to create a variable that's just day and month and then would filter as:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where put(date, mmddyy4.) = '1005';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you apply the MMDDYY4. format the summary tables should be by day/month as well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2017 16:07:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-Year-from-a-date/m-p/397815#M278342</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-09-21T16:07:18Z</dc:date>
    </item>
    <item>
      <title>Re: Removing Year from a date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-Year-from-a-date/m-p/397940#M278343</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/166693"&gt;@CRM_Ben&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The format is curently DATE9. but i'm trying to create a calculated item with, for example, 01JAN.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This will allow me to select all birthdays in on a certain date without having to condsider all the possible years they could have been born in.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;Ben&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;if month(date)=1 and day(date)=1 then do &amp;lt;whatever&amp;gt;;&lt;/P&gt;
&lt;P&gt;would find specific month and day&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have other variables with the month/day numbers you could use those instead of the 1's I used since you mentioned 01Jan.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2017 21:34:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-Year-from-a-date/m-p/397940#M278343</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-09-21T21:34:35Z</dc:date>
    </item>
    <item>
      <title>Re: Removing Year from a date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-Year-from-a-date/m-p/397946#M278344</link>
      <description>&lt;P&gt;If you're taking only a customer's month and day of birth in order to trigger some treatment of customer data or initiating communication with the customer, you may need to aggregate Feb 29 birth dates with either Mar 1 or Feb 28.&amp;nbsp; Otherwise 3 years out of 4 you might overlook persons born on leap day.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2017 22:12:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-Year-from-a-date/m-p/397946#M278344</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2017-09-21T22:12:08Z</dc:date>
    </item>
    <item>
      <title>Re: Removing Year from a date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-Year-from-a-date/m-p/397976#M278345</link>
      <description>&lt;P&gt;Try this.....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data HAVE;
format dates date9.;
  do y=2000 to 2010;
    do m=1 to 12;
      do dates=mdy(m,1,y) to intnx('month',mdy(m,1,y),0,'e');
          output;
        end;
      end;
  end;
run;


%macro SeparateByBirthMonth;
%do i=1 %to 12;
  %let var&amp;amp;i=&amp;amp;i.;
%end;

  data %do i=1 %to 12;
      want_&amp;amp;i.
       %end;;
    set HAVE;
        %do i=1 %to 12;
              %if %eval(&amp;amp;i=1) %then %do;
                if month(dates)=&amp;amp;i. then output want_&amp;amp;i.;
              %end;
                    %else %if %eval(&amp;amp;i&amp;gt;1) %then %do;
                      else if month(dates)=&amp;amp;i. then output want_&amp;amp;i.;
                    %end;
        %end;
  run;

%mend;
options macrogen;
%SeparateByBirthMonth;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Sep 2017 03:50:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-Year-from-a-date/m-p/397976#M278345</guid>
      <dc:creator>ShiroAmada</dc:creator>
      <dc:date>2017-09-22T03:50:40Z</dc:date>
    </item>
    <item>
      <title>Re: Removing Year from a date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-Year-from-a-date/m-p/398038#M278346</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/166693"&gt;@CRM_Ben&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;Using an approach as in code below should allow you to get what you're after. This approach will also deal nicely with leap years.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  format DoB date9.;
  do DoB='01Jan1995'd to '31Dec2000'd;
    output;
  end;
run;


/* select all DoB in the next 3 to 9 days based on date of &amp;amp;start_dt */
%let start_dt=28Feb2016;
data want;
  format Start_Dt DoB _Start_Dt_aligned date9.;
  set have;
  retain Start_Dt "&amp;amp;start_dt"d;

  _Start_Dt_aligned=intnx('year',Start_Dt,year(DoB)-year(Start_Dt),'s');

  if (3 &amp;lt;= (DoB - _Start_Dt_aligned) &amp;lt;= 9) then output;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 22 Sep 2017 10:47:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-Year-from-a-date/m-p/398038#M278346</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-09-22T10:47:15Z</dc:date>
    </item>
  </channel>
</rss>

