<?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: increment an age for every year between 2 dates and create a new row for each year with the new in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/increment-an-age-for-every-year-between-2-dates-and-create-a-new/m-p/929279#M365647</link>
    <description>&lt;P&gt;Pretty trivial if you add a new variable.&lt;/P&gt;
&lt;P&gt;Note: if you can't provide example data in the form of a working data step, see below, at least provide it as text pasted into a text box opened on the forum with the &amp;lt;/&amp;gt; icon. Most of us are not going to retype any significant amount of stuff from a picture.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data work.have;
   input id dob :mmddyy10. startdate :mmddyy10. enddate :mmddyy10.;
   format dob startdate enddate mmddyy10.;
datalines;
100  4/4/1968 2/12/2003 5/9/2007
200 1/29/1944 8/19/2009 9/16/2011
300 5/16/1977 3/3/2001 5/9/2007
;

data work.want;
   set work.have;
   intervalstart=startdate;
   do until (intervalstart &amp;gt; enddate);
         output;
         intervalstart=intnx('year',intervalstart,1,'S');
   end;
   format intervalstart mmddyy10.;
run;&lt;/PRE&gt;
&lt;P&gt;An exercise for the interested reader where to increment the "age".&lt;/P&gt;
&lt;P&gt;Personally i want to know which "date" an age is calculated for.&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/383433"&gt;@ItWorked&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to figure out how to expand a dataset by creating a new row for each year between a start date and end date and find the age the person is at each year between those 2 dates.&amp;nbsp; I have tried a couple of things without success.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have tried to modify this code:&amp;nbsp;&lt;A href="https://stackoverflow.com/questions/47428867/how-to-create-additional-rows-for-each-day-between-two-dates-in-sas" target="_blank" rel="noopener"&gt;https://stackoverflow.com/questions/47428867/how-to-create-additional-rows-for-each-day-between-two-dates-in-sas.&lt;/A&gt;Though the code ran successfully without errors, I did not get the intended results.&amp;nbsp; &amp;nbsp;It incremented the first observation's start date, and I need the first observation's start date to remain unchanged.&amp;nbsp; I am not certain how to proceed.&amp;nbsp;&amp;nbsp;Any assistance would be appreciated.&amp;nbsp; I am using SAS9.4.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="data have.PNG" style="width: 515px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/96670i2C6DCD0193242A92/image-size/large?v=v2&amp;amp;px=999" role="button" title="data have.PNG" alt="data have.PNG" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="data want.PNG" style="width: 518px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/96671iEBF35F9E9680C3C0/image-size/large?v=v2&amp;amp;px=999" role="button" title="data want.PNG" alt="data want.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 22 May 2024 17:20:21 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2024-05-22T17:20:21Z</dc:date>
    <item>
      <title>increment an age for every year between 2 dates and create a new row for each year with the new age</title>
      <link>https://communities.sas.com/t5/SAS-Programming/increment-an-age-for-every-year-between-2-dates-and-create-a-new/m-p/929267#M365643</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to figure out how to expand a dataset by creating a new row for each year between a start date and end date and find the age the person is at each year between those 2 dates.&amp;nbsp; I have tried a couple of things without success.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried to modify this code:&amp;nbsp;&lt;A href="https://stackoverflow.com/questions/47428867/how-to-create-additional-rows-for-each-day-between-two-dates-in-sas" target="_blank"&gt;https://stackoverflow.com/questions/47428867/how-to-create-additional-rows-for-each-day-between-two-dates-in-sas.&lt;/A&gt;Though the code ran successfully without errors, I did not get the intended results.&amp;nbsp; &amp;nbsp;It incremented the first observation's start date, and I need the first observation's start date to remain unchanged.&amp;nbsp; I am not certain how to proceed.&amp;nbsp;&amp;nbsp;Any assistance would be appreciated.&amp;nbsp; I am using SAS9.4.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="data have.PNG" style="width: 515px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/96670i2C6DCD0193242A92/image-size/large?v=v2&amp;amp;px=999" role="button" title="data have.PNG" alt="data have.PNG" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="data want.PNG" style="width: 518px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/96671iEBF35F9E9680C3C0/image-size/large?v=v2&amp;amp;px=999" role="button" title="data want.PNG" alt="data want.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 22 May 2024 16:31:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/increment-an-age-for-every-year-between-2-dates-and-create-a-new/m-p/929267#M365643</guid>
      <dc:creator>ItWorked</dc:creator>
      <dc:date>2024-05-22T16:31:50Z</dc:date>
    </item>
    <item>
      <title>Re: increment an age for every year between 2 dates and create a new row for each year with the new</title>
      <link>https://communities.sas.com/t5/SAS-Programming/increment-an-age-for-every-year-between-2-dates-and-create-a-new/m-p/929275#M365645</link>
      <description>&lt;P&gt;We can use OUTPUT statement to read the initial records, then DO LOOPS with shifting function INTNX to increment AGE and YEAR by 1 adding an extra observation for each year:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want; 
	set have;
	output; 
	do i=Year(startdate) to year(enddate)-1 by 1;
		startdate=intnx('year', startdate, 1, 'same');
		age+1;
		output;
	end;
	drop i; 
run; 
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 May 2024 17:08:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/increment-an-age-for-every-year-between-2-dates-and-create-a-new/m-p/929275#M365645</guid>
      <dc:creator>A_Kh</dc:creator>
      <dc:date>2024-05-22T17:08:09Z</dc:date>
    </item>
    <item>
      <title>Re: increment an age for every year between 2 dates and create a new row for each year with the new</title>
      <link>https://communities.sas.com/t5/SAS-Programming/increment-an-age-for-every-year-between-2-dates-and-create-a-new/m-p/929279#M365647</link>
      <description>&lt;P&gt;Pretty trivial if you add a new variable.&lt;/P&gt;
&lt;P&gt;Note: if you can't provide example data in the form of a working data step, see below, at least provide it as text pasted into a text box opened on the forum with the &amp;lt;/&amp;gt; icon. Most of us are not going to retype any significant amount of stuff from a picture.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data work.have;
   input id dob :mmddyy10. startdate :mmddyy10. enddate :mmddyy10.;
   format dob startdate enddate mmddyy10.;
datalines;
100  4/4/1968 2/12/2003 5/9/2007
200 1/29/1944 8/19/2009 9/16/2011
300 5/16/1977 3/3/2001 5/9/2007
;

data work.want;
   set work.have;
   intervalstart=startdate;
   do until (intervalstart &amp;gt; enddate);
         output;
         intervalstart=intnx('year',intervalstart,1,'S');
   end;
   format intervalstart mmddyy10.;
run;&lt;/PRE&gt;
&lt;P&gt;An exercise for the interested reader where to increment the "age".&lt;/P&gt;
&lt;P&gt;Personally i want to know which "date" an age is calculated for.&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/383433"&gt;@ItWorked&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to figure out how to expand a dataset by creating a new row for each year between a start date and end date and find the age the person is at each year between those 2 dates.&amp;nbsp; I have tried a couple of things without success.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have tried to modify this code:&amp;nbsp;&lt;A href="https://stackoverflow.com/questions/47428867/how-to-create-additional-rows-for-each-day-between-two-dates-in-sas" target="_blank" rel="noopener"&gt;https://stackoverflow.com/questions/47428867/how-to-create-additional-rows-for-each-day-between-two-dates-in-sas.&lt;/A&gt;Though the code ran successfully without errors, I did not get the intended results.&amp;nbsp; &amp;nbsp;It incremented the first observation's start date, and I need the first observation's start date to remain unchanged.&amp;nbsp; I am not certain how to proceed.&amp;nbsp;&amp;nbsp;Any assistance would be appreciated.&amp;nbsp; I am using SAS9.4.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="data have.PNG" style="width: 515px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/96670i2C6DCD0193242A92/image-size/large?v=v2&amp;amp;px=999" role="button" title="data have.PNG" alt="data have.PNG" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="data want.PNG" style="width: 518px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/96671iEBF35F9E9680C3C0/image-size/large?v=v2&amp;amp;px=999" role="button" title="data want.PNG" alt="data want.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 May 2024 17:20:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/increment-an-age-for-every-year-between-2-dates-and-create-a-new/m-p/929279#M365647</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-05-22T17:20:21Z</dc:date>
    </item>
    <item>
      <title>Re: increment an age for every year between 2 dates and create a new row for each year with the new</title>
      <link>https://communities.sas.com/t5/SAS-Programming/increment-an-age-for-every-year-between-2-dates-and-create-a-new/m-p/929295#M365653</link>
      <description>This was perfect; I appreciate you!</description>
      <pubDate>Wed, 22 May 2024 18:38:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/increment-an-age-for-every-year-between-2-dates-and-create-a-new/m-p/929295#M365653</guid>
      <dc:creator>ItWorked</dc:creator>
      <dc:date>2024-05-22T18:38:46Z</dc:date>
    </item>
    <item>
      <title>Re: increment an age for every year between 2 dates and create a new row for each year with the new</title>
      <link>https://communities.sas.com/t5/SAS-Programming/increment-an-age-for-every-year-between-2-dates-and-create-a-new/m-p/929296#M365654</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;Thank you for the tip.&amp;nbsp; I did not know this.&amp;nbsp; Thank you for re-writing the code as well.&lt;/P&gt;</description>
      <pubDate>Wed, 22 May 2024 18:42:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/increment-an-age-for-every-year-between-2-dates-and-create-a-new/m-p/929296#M365654</guid>
      <dc:creator>ItWorked</dc:creator>
      <dc:date>2024-05-22T18:42:03Z</dc:date>
    </item>
  </channel>
</rss>

