<?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: Adding the number of days to a date in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Adding-the-number-of-days-to-a-date/m-p/903931#M40350</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/391779"&gt;@Sandeep77&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35763"&gt;@yabwon&lt;/a&gt;&amp;nbsp; but the code that you suggested, does not show any date in the output data. Please see the sample output data.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data Delayed_accounts_2;				
infile cards expandtabs;				
input debt_code	rep_code$	dt_delaydays	dt_datdelay:date9.	new_date:date9.;
format dt_datdelay date9.;
datalines ;	
106444375	133	16	21MAR2013:00:00:00.000	.
345347595	168	2	23DEC2019:00:00:00.000	.
323832873	168C	10	24FEB2020:00:00:00.000	.
178669982	122	30	06SEP2017:00:00:00.000	.
;							
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;WRONG.&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Code as posted, with PROC PRINT added:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data delayed_accounts;				
infile cards expandtabs;				
input debt_code	rep_code$	dt_delaydays	dt_datdelay:date9.;
format dt_datdelay date9.;
datalines ;	
106444375	133	16	21MAR2013:00:00:00.000
345347595	168	2	23DEC2019:00:00:00.000
323832873	168C	10	24FEB2020:00:00:00.000
178669982	122	30	06SEP2017:00:00:00.000
;				
run;


Proc sql;
create table delayed_accounts_2 as
select *,
dt_datdelay + dt_delaydays as new_date format yymmdd10.
from delayed_accounts;
quit;

proc print data=delayed_accounts_2 noobs;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Log:&lt;/P&gt;
&lt;PRE&gt; 68         
 69         Data delayed_accounts;
 70         infile cards expandtabs;
 71         input debt_coderep_code$dt_delaydaysdt_datdelay:date9.;
 72         format dt_datdelay date9.;
 73         datalines ;
 
 NOTE: The data set WORK.DELAYED_ACCOUNTS has 4 observations and 4 variables.
 NOTE:  Verwendet wurde: DATA statement - (Gesamtverarbeitungszeit):
       real time           0.00 seconds
       user cpu time       0.00 seconds
       system cpu time     0.00 seconds
       memory              670.00k
       OS Memory           19368.00k
       Timestamp           20.11.2023 03:30:09 nachm.
       Step Count                        24  Switch Count  2
       Page Faults                       0
       Page Reclaims                     171
       Page Swaps                        0
       Voluntary Context Switches        11
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           264
       
 
 73       !            
 78         ;
 79         run;
 80         
 81         
 82         Proc sql;
 83         create table delayed_accounts_2 as
 84         select *,
 85         dt_datdelay + dt_delaydays as new_date format yymmdd10.
 86         from delayed_accounts;
 NOTE: Table WORK.DELAYED_ACCOUNTS_2 created, with 4 rows and 5 columns.
 
 87         quit;
 NOTE:  Verwendet wurde: PROZEDUR SQL - (Gesamtverarbeitungszeit):
       real time           0.00 seconds
       user cpu time       0.01 seconds
       system cpu time     0.00 seconds
       memory              5630.87k
       OS Memory           24748.00k
       Timestamp           20.11.2023 03:30:09 nachm.
       Step Count                        25  Switch Count  2
       Page Faults                       0
       Page Reclaims                     200
       Page Swaps                        0
       Voluntary Context Switches        12
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           264
       
 
 88         
 89         proc print data=delayed_accounts_2 noobs;
 90         run;
 
 NOTE: There were 4 observations read from the data set WORK.DELAYED_ACCOUNTS_2.
 NOTE:  Verwendet wurde: PROZEDUR PRINT - (Gesamtverarbeitungszeit):
       real time           0.00 seconds
       user cpu time       0.00 seconds
       system cpu time     0.01 seconds
       memory              1244.25k
       OS Memory           20648.00k
       Timestamp           20.11.2023 03:30:09 nachm.
       Step Count                        26  Switch Count  0
       Page Faults                       0
       Page Reclaims                     465
       Page Swaps                        0
       Voluntary Context Switches        0
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           8
&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;debt_code	rep_code	dt_delaydays	dt_datdelay	new_date
106444375	133	16	21MAR2013	2013-04-06
345347595	168	2	23DEC2019	2019-12-25
323832873	168C	10	24FEB2020	2020-03-05
178669982	122	30	06SEP2017	2017-10-06
&lt;/PRE&gt;
&lt;P&gt;As you can see, the result are non-missing values, cleanly formatted as dates.&lt;/P&gt;</description>
    <pubDate>Mon, 20 Nov 2023 15:33:28 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2023-11-20T15:33:28Z</dc:date>
    <item>
      <title>Adding the number of days to a date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Adding-the-number-of-days-to-a-date/m-p/903909#M40345</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;I have a dataset which has&amp;nbsp;dt_delaydays and&amp;nbsp;dt_datdelay columns.&amp;nbsp;dt_delaydays is showing the number of days and&amp;nbsp;dt_datdelay is showing the date. I am trying to add a new column (say new_date) which add the number of days (dt_delaydays) to the date (dt_datdelay) and gives the output in a date format in the new_date column. For e.g., 5 + 12/09/2023 will show 17/09/2023 in the new date column. My code does not show any date in the new_date column.&lt;/P&gt;
&lt;P&gt;Here is the sample dataset:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data delayed_accounts;				
infile cards expandtabs;				
input debt_code	rep_code$	dt_delaydays	dt_datdelay:date9.;
format dt_datdelay date9.;
datalines ;	
106444375	133	16	21MAR2013:00:00:00.000
345347595	168	2	23DEC2019:00:00:00.000
323832873	168C	10	24FEB2020:00:00:00.000
178669982	122	30	06SEP2017:00:00:00.000
;				
run;
My code:
Proc sql;
create table delayed_accounts as 
select *,
intnx('day', dt_datdelay, dt_delaydays) as new_date
from Accounts_in_trace;
quit;
Log:
29         Proc sql;
30         create table delayed_accounts as
31         select *,
32         intnx('day', dt_datdelay, dt_delaydays) as new_date
33         from Accounts_in_trace;
NOTE: Invalid argument to function INTNX. Missing values may be generated.
NOTE: Compressing data set WORK.DELAYED_ACCOUNTS decreased size by 23.29 percent. 
      Compressed is 168 pages; un-compressed would require 219 pages.
NOTE: Table WORK.DELAYED_ACCOUNTS created, with 254537 rows and 5 columns.

34         quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 20 Nov 2023 14:20:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Adding-the-number-of-days-to-a-date/m-p/903909#M40345</guid>
      <dc:creator>Sandeep77</dc:creator>
      <dc:date>2023-11-20T14:20:50Z</dc:date>
    </item>
    <item>
      <title>Re: Adding the number of days to a date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Adding-the-number-of-days-to-a-date/m-p/903915#M40346</link>
      <description>&lt;P&gt;Date in SAS (also the one used in Proc SQL) is a "number of days which remained since 1 January 1960", for example&amp;nbsp;19-OCT-1993 is 12345.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So if you want to add for example 5 days to a date in SAS you can just write:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* in Data Step */

newDatevariable = dateVariable + 5 ;

/* or in SQL */

dateVariable + 5 as newDatevariable &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2023 14:55:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Adding-the-number-of-days-to-a-date/m-p/903915#M40346</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2023-11-20T14:55:33Z</dc:date>
    </item>
    <item>
      <title>Re: Adding the number of days to a date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Adding-the-number-of-days-to-a-date/m-p/903916#M40347</link>
      <description>&lt;P&gt;Your code, modified:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data delayed_accounts;				
infile cards expandtabs;				
input debt_code	rep_code$	dt_delaydays	dt_datdelay:date9.;
format dt_datdelay date9.;
datalines ;	
106444375	133	16	21MAR2013:00:00:00.000
345347595	168	2	23DEC2019:00:00:00.000
323832873	168C	10	24FEB2020:00:00:00.000
178669982	122	30	06SEP2017:00:00:00.000
;				
run;


Proc sql;
create table delayed_accounts_2 as
select *,
dt_datdelay + dt_delaydays as new_date format yymmdd10.
from delayed_accounts;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2023 14:58:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Adding-the-number-of-days-to-a-date/m-p/903916#M40347</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2023-11-20T14:58:19Z</dc:date>
    </item>
    <item>
      <title>Re: Adding the number of days to a date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Adding-the-number-of-days-to-a-date/m-p/903924#M40348</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35763"&gt;@yabwon&lt;/a&gt;&amp;nbsp; but the code that you suggested, does not show any date in the output data. Please see the sample output data.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data Delayed_accounts_2;				
infile cards expandtabs;				
input debt_code	rep_code$	dt_delaydays	dt_datdelay:date9.	new_date:date9.;
format dt_datdelay date9.;
datalines ;	
106444375	133	16	21MAR2013:00:00:00.000	.
345347595	168	2	23DEC2019:00:00:00.000	.
323832873	168C	10	24FEB2020:00:00:00.000	.
178669982	122	30	06SEP2017:00:00:00.000	.
;							
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 20 Nov 2023 15:06:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Adding-the-number-of-days-to-a-date/m-p/903924#M40348</guid>
      <dc:creator>Sandeep77</dc:creator>
      <dc:date>2023-11-20T15:06:02Z</dc:date>
    </item>
    <item>
      <title>Re: Adding the number of days to a date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Adding-the-number-of-days-to-a-date/m-p/903926#M40349</link>
      <description>&lt;P&gt;I dare to disagree (see screen shot below).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Did you go with &lt;A title="https://communities.sas.com/t5/SAS-Communities-Library/Maxims-of-Maximally-Efficient-SAS-Programmers/ta-p/352068/show-comments/false" href="https://communities.sas.com/t5/SAS-Communities-Library/Maxims-of-Maximally-Efficient-SAS-Programmers/ta-p/352068/show-comments/false" target="_self"&gt;Maxim2 and Maxim3&lt;/A&gt; ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="yabwon_0-1700493459710.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/90041i34C708C7221AE472/image-size/medium?v=v2&amp;amp;px=400" role="button" title="yabwon_0-1700493459710.png" alt="yabwon_0-1700493459710.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2023 15:19:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Adding-the-number-of-days-to-a-date/m-p/903926#M40349</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2023-11-20T15:19:11Z</dc:date>
    </item>
    <item>
      <title>Re: Adding the number of days to a date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Adding-the-number-of-days-to-a-date/m-p/903931#M40350</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/391779"&gt;@Sandeep77&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35763"&gt;@yabwon&lt;/a&gt;&amp;nbsp; but the code that you suggested, does not show any date in the output data. Please see the sample output data.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data Delayed_accounts_2;				
infile cards expandtabs;				
input debt_code	rep_code$	dt_delaydays	dt_datdelay:date9.	new_date:date9.;
format dt_datdelay date9.;
datalines ;	
106444375	133	16	21MAR2013:00:00:00.000	.
345347595	168	2	23DEC2019:00:00:00.000	.
323832873	168C	10	24FEB2020:00:00:00.000	.
178669982	122	30	06SEP2017:00:00:00.000	.
;							
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;WRONG.&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Code as posted, with PROC PRINT added:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data delayed_accounts;				
infile cards expandtabs;				
input debt_code	rep_code$	dt_delaydays	dt_datdelay:date9.;
format dt_datdelay date9.;
datalines ;	
106444375	133	16	21MAR2013:00:00:00.000
345347595	168	2	23DEC2019:00:00:00.000
323832873	168C	10	24FEB2020:00:00:00.000
178669982	122	30	06SEP2017:00:00:00.000
;				
run;


Proc sql;
create table delayed_accounts_2 as
select *,
dt_datdelay + dt_delaydays as new_date format yymmdd10.
from delayed_accounts;
quit;

proc print data=delayed_accounts_2 noobs;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Log:&lt;/P&gt;
&lt;PRE&gt; 68         
 69         Data delayed_accounts;
 70         infile cards expandtabs;
 71         input debt_coderep_code$dt_delaydaysdt_datdelay:date9.;
 72         format dt_datdelay date9.;
 73         datalines ;
 
 NOTE: The data set WORK.DELAYED_ACCOUNTS has 4 observations and 4 variables.
 NOTE:  Verwendet wurde: DATA statement - (Gesamtverarbeitungszeit):
       real time           0.00 seconds
       user cpu time       0.00 seconds
       system cpu time     0.00 seconds
       memory              670.00k
       OS Memory           19368.00k
       Timestamp           20.11.2023 03:30:09 nachm.
       Step Count                        24  Switch Count  2
       Page Faults                       0
       Page Reclaims                     171
       Page Swaps                        0
       Voluntary Context Switches        11
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           264
       
 
 73       !            
 78         ;
 79         run;
 80         
 81         
 82         Proc sql;
 83         create table delayed_accounts_2 as
 84         select *,
 85         dt_datdelay + dt_delaydays as new_date format yymmdd10.
 86         from delayed_accounts;
 NOTE: Table WORK.DELAYED_ACCOUNTS_2 created, with 4 rows and 5 columns.
 
 87         quit;
 NOTE:  Verwendet wurde: PROZEDUR SQL - (Gesamtverarbeitungszeit):
       real time           0.00 seconds
       user cpu time       0.01 seconds
       system cpu time     0.00 seconds
       memory              5630.87k
       OS Memory           24748.00k
       Timestamp           20.11.2023 03:30:09 nachm.
       Step Count                        25  Switch Count  2
       Page Faults                       0
       Page Reclaims                     200
       Page Swaps                        0
       Voluntary Context Switches        12
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           264
       
 
 88         
 89         proc print data=delayed_accounts_2 noobs;
 90         run;
 
 NOTE: There were 4 observations read from the data set WORK.DELAYED_ACCOUNTS_2.
 NOTE:  Verwendet wurde: PROZEDUR PRINT - (Gesamtverarbeitungszeit):
       real time           0.00 seconds
       user cpu time       0.00 seconds
       system cpu time     0.01 seconds
       memory              1244.25k
       OS Memory           20648.00k
       Timestamp           20.11.2023 03:30:09 nachm.
       Step Count                        26  Switch Count  0
       Page Faults                       0
       Page Reclaims                     465
       Page Swaps                        0
       Voluntary Context Switches        0
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           8
&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;debt_code	rep_code	dt_delaydays	dt_datdelay	new_date
106444375	133	16	21MAR2013	2013-04-06
345347595	168	2	23DEC2019	2019-12-25
323832873	168C	10	24FEB2020	2020-03-05
178669982	122	30	06SEP2017	2017-10-06
&lt;/PRE&gt;
&lt;P&gt;As you can see, the result are non-missing values, cleanly formatted as dates.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2023 15:33:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Adding-the-number-of-days-to-a-date/m-p/903931#M40350</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-11-20T15:33:28Z</dc:date>
    </item>
  </channel>
</rss>

