<?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 Creating date from existing date field in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creating-date-from-existing-date-field/m-p/834312#M329870</link>
    <description>&lt;P&gt;I am attempting to create a new date field in a dataset based on an existing date field.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm looking to create a new field 'end_date' that is 60 days after various dates in a dataset in column 'existing_date'.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;format end_date date9.;&lt;/P&gt;&lt;P&gt;end_date = intck('days',existing_date,60);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below are my results.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Sas_noob25_0-1663689397170.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/75403i56A7B56FE8E44197/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Sas_noob25_0-1663689397170.png" alt="Sas_noob25_0-1663689397170.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Thank you in advance!&lt;/P&gt;</description>
    <pubDate>Tue, 20 Sep 2022 15:57:29 GMT</pubDate>
    <dc:creator>Sas_noob25</dc:creator>
    <dc:date>2022-09-20T15:57:29Z</dc:date>
    <item>
      <title>Creating date from existing date field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-date-from-existing-date-field/m-p/834312#M329870</link>
      <description>&lt;P&gt;I am attempting to create a new date field in a dataset based on an existing date field.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm looking to create a new field 'end_date' that is 60 days after various dates in a dataset in column 'existing_date'.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;format end_date date9.;&lt;/P&gt;&lt;P&gt;end_date = intck('days',existing_date,60);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below are my results.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Sas_noob25_0-1663689397170.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/75403i56A7B56FE8E44197/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Sas_noob25_0-1663689397170.png" alt="Sas_noob25_0-1663689397170.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Thank you in advance!&lt;/P&gt;</description>
      <pubDate>Tue, 20 Sep 2022 15:57:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-date-from-existing-date-field/m-p/834312#M329870</guid>
      <dc:creator>Sas_noob25</dc:creator>
      <dc:date>2022-09-20T15:57:29Z</dc:date>
    </item>
    <item>
      <title>Re: Creating date from existing date field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-date-from-existing-date-field/m-p/834314#M329872</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/284312"&gt;@Sas_noob25&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Replace &lt;FONT face="courier new,courier"&gt;intck&lt;/FONT&gt; with &lt;FONT face="courier new,courier"&gt;int&lt;STRONG&gt;nx&lt;/STRONG&gt;&lt;/FONT&gt; and it should work.&lt;/P&gt;
&lt;P&gt;Or simply write&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;end_date = existing_date+60;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Sep 2022 16:08:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-date-from-existing-date-field/m-p/834314#M329872</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2022-09-20T16:08:01Z</dc:date>
    </item>
    <item>
      <title>Re: Creating date from existing date field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-date-from-existing-date-field/m-p/834315#M329873</link>
      <description>INTCK calculates intervals between two dates. &lt;BR /&gt;INTNX increments dates.&lt;BR /&gt;&lt;BR /&gt;end_date = intnx('day', existing_date, 60);&lt;BR /&gt;end_date = existing_date + 60;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 20 Sep 2022 16:12:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-date-from-existing-date-field/m-p/834315#M329873</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-09-20T16:12:08Z</dc:date>
    </item>
    <item>
      <title>Re: Creating date from existing date field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-date-from-existing-date-field/m-p/834316#M329874</link>
      <description>&lt;P&gt;Your code is counting how many day intervals there are between the start date and day number 60 (which is the first day of March in the year 1960) .&amp;nbsp; That will be a very large negative number.&amp;nbsp; Since day zero is January first of 1960 you can see why you ended up with dates that are in the 19th century.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to add 60 days to the number of days that are stored in EXISTING_DATE then addition is the simplest way.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;end_date = existing_date+60;
format end_date date9.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want to add a multiple of some other interval that is NOT the unit that the value is already stored in then you could use the INTNX() function instead of the INTCK() function.&amp;nbsp; &amp;nbsp;For example if you wanted to add two months you could use the MONTH interval.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;end_date = intnx('month',existing_date,2,'s');&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 20 Sep 2022 16:14:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-date-from-existing-date-field/m-p/834316#M329874</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-09-20T16:14:47Z</dc:date>
    </item>
    <item>
      <title>Re: Creating date from existing date field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-date-from-existing-date-field/m-p/834331#M329877</link>
      <description>&lt;P&gt;Possibly a silly question. Is that 60 days used as a substitute for "two months"? As in what is the expected result of 60 days after 25Mar2022?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want 25May2022, the same day of the two months later, then you would use Intnx('month',date,2,'s');&lt;/P&gt;</description>
      <pubDate>Tue, 20 Sep 2022 17:07:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-date-from-existing-date-field/m-p/834331#M329877</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-09-20T17:07:22Z</dc:date>
    </item>
    <item>
      <title>Re: Creating date from existing date field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-date-from-existing-date-field/m-p/834334#M329878</link>
      <description>&lt;P&gt;Thank you, both of these worked out for me. in the intnx function, what is the 's' doing at the end?&lt;/P&gt;</description>
      <pubDate>Tue, 20 Sep 2022 17:25:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-date-from-existing-date-field/m-p/834334#M329878</guid>
      <dc:creator>Sas_noob25</dc:creator>
      <dc:date>2022-09-20T17:25:40Z</dc:date>
    </item>
    <item>
      <title>Re: Creating date from existing date field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-date-from-existing-date-field/m-p/834335#M329879</link>
      <description>&lt;P&gt;Thank you! Both of these options worked.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Sep 2022 17:26:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-date-from-existing-date-field/m-p/834335#M329879</guid>
      <dc:creator>Sas_noob25</dc:creator>
      <dc:date>2022-09-20T17:26:09Z</dc:date>
    </item>
    <item>
      <title>Re: Creating date from existing date field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-date-from-existing-date-field/m-p/834347#M329881</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/284312"&gt;@Sas_noob25&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you, both of these worked out for me. in the intnx function, what is the 's' doing at the end?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Read the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/v_030/ds2ref/n1mtvizfg1y0g9n1wslqgjxseh0i.htm" target="_self"&gt;documentation&lt;/A&gt;.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H4 class="xisDoc-argument"&gt;'&lt;EM class="xisDoc-userSuppliedValue"&gt;alignment&lt;/EM&gt;'&lt;/H4&gt;
&lt;DIV class="xisDoc-argumentDescription"&gt;
&lt;P class="xisDoc-paraSimpleFirst"&gt;controls the position of SAS dates within the interval. You must enclose&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;EM class="xisDoc-userSuppliedValue"&gt;alignment&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;in quotation marks.&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;EM class="xisDoc-userSuppliedValue"&gt;Alignment&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;can be one of these values: BEGINNING, MIDDLE, END, and SAME. SAME specifies that the date that is returned has the same alignment as the input date. For more information, see SAS DS2 Language Reference.&lt;/P&gt;
&lt;P class="xisDoc-paraSimple"&gt;controls the position of SAS dates within the interval. You must enclose&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;EM class="xisDoc-userSuppliedValue"&gt;alignment&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;in quotation marks.&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;EM class="xisDoc-userSuppliedValue"&gt;Alignment&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;can be one of these values:&lt;/P&gt;
&lt;DIV id="n0m1y19p7lmudgn1uyntcbb24o25" class="xisDoc-argDescriptionPair"&gt;
&lt;H4 class="xisDoc-argument"&gt;BEGINNING&lt;/H4&gt;
&lt;DIV class="xisDoc-argumentDescription"&gt;
&lt;P class="xisDoc-paraSimpleFirst"&gt;specifies that the returned date or datetime value is aligned to the beginning of the interval.&lt;/P&gt;
&lt;SECTION class="xisDoc-tableWrap"&gt;
&lt;TABLE class="xisDoc-summary"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="xisDoc-alias"&gt;Alias&lt;/TH&gt;
&lt;TD class="xisDoc-summaryText"&gt;B&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/SECTION&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV id="p041vc6dd1s20pn17q241mhlk2i8" class="xisDoc-argDescriptionPair"&gt;
&lt;H4 class="xisDoc-argument"&gt;MIDDLE&lt;/H4&gt;
&lt;DIV class="xisDoc-argumentDescription"&gt;
&lt;P class="xisDoc-paraSimpleFirst"&gt;specifies that the returned date or datetime value is aligned to the midpoint of the interval, which is the average of the beginning and ending alignment values.&lt;/P&gt;
&lt;SECTION class="xisDoc-tableWrap"&gt;
&lt;TABLE class="xisDoc-summary"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="xisDoc-alias"&gt;Alias&lt;/TH&gt;
&lt;TD class="xisDoc-summaryText"&gt;M&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/SECTION&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV id="p0rtr5uusloumfn1855s4oqlaunl" class="xisDoc-argDescriptionPair"&gt;
&lt;H4 class="xisDoc-argument"&gt;END&lt;/H4&gt;
&lt;DIV class="xisDoc-argumentDescription"&gt;
&lt;P class="xisDoc-paraSimpleFirst"&gt;specifies that the returned date or datetime value is aligned to the end of the interval.&lt;/P&gt;
&lt;SECTION class="xisDoc-tableWrap"&gt;
&lt;TABLE class="xisDoc-summary"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="xisDoc-alias"&gt;Alias&lt;/TH&gt;
&lt;TD class="xisDoc-summaryText"&gt;E&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/SECTION&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV id="n06ae04vw2jtemn1j4xjr4zptks7" class="xisDoc-argDescriptionPair"&gt;
&lt;H4 class="xisDoc-argument"&gt;SAME&lt;/H4&gt;
&lt;DIV class="xisDoc-argumentDescription"&gt;
&lt;P class="xisDoc-paraSimpleFirst"&gt;specifies that the date that is returned has the same alignment as the input date.&lt;/P&gt;
&lt;SECTION class="xisDoc-tableWrap"&gt;
&lt;TABLE class="xisDoc-summary"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="xisDoc-alias" rowspan="2"&gt;Aliases&lt;/TH&gt;
&lt;TD class="xisDoc-summaryText"&gt;S&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="xisDoc-summaryText"&gt;SAMEDAY&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="xisDoc-summarySee"&gt;See&lt;/TH&gt;
&lt;TD class="xisDoc-summaryText"&gt;&lt;A tabindex="0" href="https://documentation.sas.com/doc/en/pgmsascdc/v_030/ds2ref/n1mtvizfg1y0g9n1wslqgjxseh0i.htm#n1gfk3qwmkapq1n1819j7d57g5w9" target="_blank"&gt;SAME Alignment&lt;/A&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/SECTION&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;SECTION class="xisDoc-tableWrap"&gt;
&lt;TABLE class="xisDoc-summary"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="xisDoc-summaryDefault"&gt;Default&lt;/TH&gt;
&lt;TD class="xisDoc-summaryText"&gt;BEGINNING&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="xisDoc-dataType"&gt;Data type&lt;/TH&gt;
&lt;TD class="xisDoc-summaryText"&gt;CHAR, NCHAR, NVARCHAR, VARCHAR&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="xisDoc-summarySee"&gt;See&lt;/TH&gt;
&lt;TD class="xisDoc-summaryText"&gt;&lt;A tabindex="0" href="https://documentation.sas.com/doc/en/pgmsascdc/v_030/ds2ref/n1mtvizfg1y0g9n1wslqgjxseh0i.htm#p07iudnt5rhhhxn1bxi0qxqbrfql" target="_blank"&gt;Aligning SAS Date Output within Its Intervals&lt;/A&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/SECTION&gt;
&lt;/DIV&gt;</description>
      <pubDate>Tue, 20 Sep 2022 18:10:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-date-from-existing-date-field/m-p/834347#M329881</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-09-20T18:10:02Z</dc:date>
    </item>
  </channel>
</rss>

