<?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 Summing months in dates in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Summing-months-in-dates/m-p/18768#M2855</link>
    <description>Hi there,&lt;BR /&gt;
&lt;BR /&gt;
I'me havind some trouble summing some dates.&lt;BR /&gt;
&lt;BR /&gt;
I have a table with a column with Begin_Date and another colunm with&lt;BR /&gt;
Maturity_Lenght.&lt;BR /&gt;
&lt;BR /&gt;
I need to create another column with the End_Date, by adding the&lt;BR /&gt;
Maturity_Lenght to the Begin_Date.&lt;BR /&gt;
&lt;BR /&gt;
Begin_Date         Maturity_Lenght (month)            End_Date&lt;BR /&gt;
&lt;BR /&gt;
02-05-2008                        1&lt;BR /&gt;
02-06-2008&lt;BR /&gt;
&lt;BR /&gt;
05-05-2008                        3&lt;BR /&gt;
05-08-2008&lt;BR /&gt;
                                .....&lt;BR /&gt;
&lt;BR /&gt;
How can I do that?&lt;BR /&gt;
&lt;BR /&gt;
data mylib.txcp_copy;&lt;BR /&gt;
SET mylib.txcurtoprazo;&lt;BR /&gt;
IF      Prazo='D01'     THEN DO&lt;BR /&gt;
       End_Date=Data_valor+1;&lt;BR /&gt;
       END;&lt;BR /&gt;
IF      Prazo='D07'     THEN DO&lt;BR /&gt;
       End_Date=Data_valor+7;&lt;BR /&gt;
       END;&lt;BR /&gt;
IF      Prazo='D14' THEN DO&lt;BR /&gt;
       End_Date=Data_valor+14;&lt;BR /&gt;
END;&lt;BR /&gt;
&lt;BR /&gt;
/* adding 3 months to the iniciao date (data_valor)*/&lt;BR /&gt;
IF      Prazo='M03'     THEN DO&lt;BR /&gt;
&lt;BR /&gt;
end_date=intnx('month',Data_Valor,3,"sameday");&lt;BR /&gt;
&lt;BR /&gt;
       END;&lt;BR /&gt;
run;</description>
    <pubDate>Mon, 19 May 2008 13:55:32 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2008-05-19T13:55:32Z</dc:date>
    <item>
      <title>Summing months in dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summing-months-in-dates/m-p/18768#M2855</link>
      <description>Hi there,&lt;BR /&gt;
&lt;BR /&gt;
I'me havind some trouble summing some dates.&lt;BR /&gt;
&lt;BR /&gt;
I have a table with a column with Begin_Date and another colunm with&lt;BR /&gt;
Maturity_Lenght.&lt;BR /&gt;
&lt;BR /&gt;
I need to create another column with the End_Date, by adding the&lt;BR /&gt;
Maturity_Lenght to the Begin_Date.&lt;BR /&gt;
&lt;BR /&gt;
Begin_Date         Maturity_Lenght (month)            End_Date&lt;BR /&gt;
&lt;BR /&gt;
02-05-2008                        1&lt;BR /&gt;
02-06-2008&lt;BR /&gt;
&lt;BR /&gt;
05-05-2008                        3&lt;BR /&gt;
05-08-2008&lt;BR /&gt;
                                .....&lt;BR /&gt;
&lt;BR /&gt;
How can I do that?&lt;BR /&gt;
&lt;BR /&gt;
data mylib.txcp_copy;&lt;BR /&gt;
SET mylib.txcurtoprazo;&lt;BR /&gt;
IF      Prazo='D01'     THEN DO&lt;BR /&gt;
       End_Date=Data_valor+1;&lt;BR /&gt;
       END;&lt;BR /&gt;
IF      Prazo='D07'     THEN DO&lt;BR /&gt;
       End_Date=Data_valor+7;&lt;BR /&gt;
       END;&lt;BR /&gt;
IF      Prazo='D14' THEN DO&lt;BR /&gt;
       End_Date=Data_valor+14;&lt;BR /&gt;
END;&lt;BR /&gt;
&lt;BR /&gt;
/* adding 3 months to the iniciao date (data_valor)*/&lt;BR /&gt;
IF      Prazo='M03'     THEN DO&lt;BR /&gt;
&lt;BR /&gt;
end_date=intnx('month',Data_Valor,3,"sameday");&lt;BR /&gt;
&lt;BR /&gt;
       END;&lt;BR /&gt;
run;</description>
      <pubDate>Mon, 19 May 2008 13:55:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summing-months-in-dates/m-p/18768#M2855</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-05-19T13:55:32Z</dc:date>
    </item>
    <item>
      <title>Re: Summing months in dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summing-months-in-dates/m-p/18769#M2856</link>
      <description>Your maturity length appears to be a character variable, which is probably part of the problem that led you down this path.&lt;BR /&gt;
&lt;BR /&gt;
I would check this value for its first character and if it is "D" then I would set the interval type to be "Day" and retrieve the other part of the month as a number with something like&lt;BR /&gt;
&lt;BR /&gt;
  DAYS = Input( Substr( LENGTH, 1, 2), 2.);&lt;BR /&gt;
&lt;BR /&gt;
Then calculate the new end date with an appropriate call to the IntNx() function.&lt;BR /&gt;
&lt;BR /&gt;
You should also use  "Else If"  where you have mutually exclusive conditions.  It creates neater code that executes in marginally less time.&lt;BR /&gt;
&lt;BR /&gt;
Kind regards&lt;BR /&gt;
&lt;BR /&gt;
David</description>
      <pubDate>Tue, 20 May 2008 02:56:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summing-months-in-dates/m-p/18769#M2856</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-05-20T02:56:47Z</dc:date>
    </item>
    <item>
      <title>Re: Summing months in dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summing-months-in-dates/m-p/18770#M2857</link>
      <description>Thanks so much for your help.</description>
      <pubDate>Tue, 20 May 2008 14:44:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summing-months-in-dates/m-p/18770#M2857</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-05-20T14:44:50Z</dc:date>
    </item>
  </channel>
</rss>

