<?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: Appending specific year to an extracted month and day in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Appending-specific-year-to-an-extracted-month-and-day/m-p/852578#M337013</link>
    <description>&lt;P&gt;Thanks for you response. The reason I am interested in extracting the specific month and day is that is &lt;SPAN&gt;I have another variable (date of enrollment), and I'd like to find their age at this date.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For&amp;nbsp;&lt;SPAN&gt;A2543 in my example, they are 18 after their birthday of&amp;nbsp;08OCT2018 and before their next birthday 08OCT2019. If their enrollment date was on 01JUN2019, they would be 18 on this day. Your solution would yield age_2019 of 19, which would not be what I want.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Apologies for not including this piece in my original post.&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 06 Jan 2023 22:13:17 GMT</pubDate>
    <dc:creator>gabagotati</dc:creator>
    <dc:date>2023-01-06T22:13:17Z</dc:date>
    <item>
      <title>Appending specific year to an extracted month and day</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Appending-specific-year-to-an-extracted-month-and-day/m-p/852573#M337008</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset with unique IDs and date of births, and I would like to calculate their age from future birthdays in specific years (for example, 2018 and 2019). I understand how to calculate age between two dates, but am having trouble with creating the dates of the future birthdays&amp;nbsp; in the first place. In other words, I'd like to take the month and day of their birthday, and append to a specified year.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Have:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ID_1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; DOB&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;A2543&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 08OCT1993&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;A3667&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 12JUL2003&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;A3624&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 30MAR2000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Want:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ID_1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; DOB&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;bday_2018&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; bday_2019&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;age_2018&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;age_2019&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;A2543&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 08OCT1993&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 08OCT2018&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;08OCT2019&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 26&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;27&lt;/P&gt;&lt;P&gt;A3667&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 12JUL2003&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;12JUL2018&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;12JUL2019&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;15&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;16&lt;/P&gt;&lt;P&gt;A3624&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 30MAR2000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;30MAR2018&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;30MAR2019&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 18&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 19&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2023 21:53:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Appending-specific-year-to-an-extracted-month-and-day/m-p/852573#M337008</guid>
      <dc:creator>gabagotati</dc:creator>
      <dc:date>2023-01-06T21:53:48Z</dc:date>
    </item>
    <item>
      <title>Re: Appending specific year to an extracted month and day</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Appending-specific-year-to-an-extracted-month-and-day/m-p/852575#M337010</link>
      <description>&lt;P&gt;You're making this way more difficult than it needs to be.&amp;nbsp; If you want to use the same day and month, you don't have to use month and day.&amp;nbsp; You need one of these:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;age_2018 = 2018 - year(dob);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Looking at the calculations you have already made, you may be looking at a variation:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;age_2018 = 2018 + 1 - year(dob);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But I would expect the first formula is the correct one.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2023 22:06:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Appending-specific-year-to-an-extracted-month-and-day/m-p/852575#M337010</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2023-01-06T22:06:36Z</dc:date>
    </item>
    <item>
      <title>Re: Appending specific year to an extracted month and day</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Appending-specific-year-to-an-extracted-month-and-day/m-p/852578#M337013</link>
      <description>&lt;P&gt;Thanks for you response. The reason I am interested in extracting the specific month and day is that is &lt;SPAN&gt;I have another variable (date of enrollment), and I'd like to find their age at this date.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For&amp;nbsp;&lt;SPAN&gt;A2543 in my example, they are 18 after their birthday of&amp;nbsp;08OCT2018 and before their next birthday 08OCT2019. If their enrollment date was on 01JUN2019, they would be 18 on this day. Your solution would yield age_2019 of 19, which would not be what I want.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Apologies for not including this piece in my original post.&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2023 22:13:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Appending-specific-year-to-an-extracted-month-and-day/m-p/852578#M337013</guid>
      <dc:creator>gabagotati</dc:creator>
      <dc:date>2023-01-06T22:13:17Z</dc:date>
    </item>
    <item>
      <title>Re: Appending specific year to an extracted month and day</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Appending-specific-year-to-an-extracted-month-and-day/m-p/852607#M337016</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/432214"&gt;@gabagotati&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks for you response. The reason I am interested in extracting the specific month and day is that is &lt;SPAN&gt;I have another variable (date of enrollment), and I'd like to find their age at this date.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For&amp;nbsp;&lt;SPAN&gt;A2543 in my example, they are 18 after their birthday of&amp;nbsp;08OCT2018 and before their next birthday 08OCT2019. If their enrollment date was on 01JUN2019, they would be 18 on this day. Your solution would yield age_2019 of 19, which would not be what I want.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Apologies for not including this piece in my original post.&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If you have another DATE valued variable then the YRDIF function may&amp;nbsp; be what you want:&lt;/P&gt;
&lt;PRE&gt;ageatdate = floor( yrdif(dob,enrollmentdate) );
&lt;/PRE&gt;
&lt;P&gt;This will return a decimal portion. So you may want to use the FLOOR function to remove the decimal bit:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2023 22:23:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Appending-specific-year-to-an-extracted-month-and-day/m-p/852607#M337016</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-01-06T22:23:35Z</dc:date>
    </item>
    <item>
      <title>Re: Appending specific year to an extracted month and day</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Appending-specific-year-to-an-extracted-month-and-day/m-p/852609#M337018</link>
      <description>&lt;P&gt;I think you have chosen a poor layout of the data to do this. A better layout would be&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Want:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;ID_1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; DOB&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; year &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; age&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;A2543&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 08OCT1993&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; 2018 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 26&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A2543&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 08OCT1993&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2019&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 27&lt;/P&gt;
&lt;P&gt;A3667&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 12JUL2003&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2018&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 15&lt;/P&gt;
&lt;P&gt;A3667&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 12JUL2003&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2019 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 16&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/432214"&gt;@gabagotati&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks for you response. The reason I am interested in extracting the specific month and day is that is &lt;SPAN&gt;I have another variable (date of enrollment), and I'd like to find their age at this date.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For&amp;nbsp;&lt;SPAN&gt;A2543 in my example, they are 18 after their birthday of&amp;nbsp;08OCT2018 and before their next birthday 08OCT2019. If their enrollment date was on 01JUN2019, they would be 18 on this day. Your solution would yield age_2019 of 19, which would not be what I want.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Apologies for not including this piece in my original post.&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;However, to address the problem you now state, I make up some data and address the solution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input ID $ DOB :date9. date_of_enrollment :date9.;      
cards;
A2543 08OCT1993 01JUN2019                
A3667 12JUL2003 12JUL2020   
A3624 30MAR2000 19JAN2021
;

data want;
    set have;
    age_at_enrollment = intck('year',dob,date_of_enrollment,'c');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2023 22:29:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Appending-specific-year-to-an-extracted-month-and-day/m-p/852609#M337018</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-01-06T22:29:52Z</dc:date>
    </item>
  </channel>
</rss>

