<?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: SAS macro date with d at end in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-date-with-d-at-end/m-p/754974#M238188</link>
    <description>&lt;P&gt;It is not really necessary to use INTNX() to add days since SAS stores dates as number of days.&amp;nbsp; Just use normal arithmetic.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The QUOTE() function can be used to add quotes.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data ttt;
  format date date9.;
  input date :date9.;
cards;
21feb2020
31dec2020
04Mar2021
19mar2021
28Jun2021
;

proc sql noprint;
select max(date)+1 
     , cats(quote(put(max(date)+1,date9.)),'d')
  into :start_date trimmed
     , :start_date_human 
  from  ttt
;
quit;

%put &amp;amp;=start_date &amp;amp;=start_date_human ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;START_DATE=22460 START_DATE_HUMAN="29JUN2021"d
&lt;/PRE&gt;
&lt;P&gt;Note that both forms refer to the same day and can be used it most of the same places.&amp;nbsp; The only restriction is you cannot use the human readable date literal with the %EVAL() macro function.&amp;nbsp; You would need to use %SYSEVALF() if you want the macro process to see that string as a date.&lt;/P&gt;</description>
    <pubDate>Mon, 19 Jul 2021 12:46:41 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2021-07-19T12:46:41Z</dc:date>
    <item>
      <title>SAS macro date with d at end</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-date-with-d-at-end/m-p/754908#M238159</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;What is the way to create a SAS date macro variable with d at the end?&lt;/P&gt;
&lt;P&gt;The resulted value in this case should be '&lt;CODE class=" language-sas"&gt;21feb2020'd&amp;nbsp;&amp;nbsp;(one&amp;nbsp;day&amp;nbsp;after&amp;nbsp;max&amp;nbsp;date&amp;nbsp;in&amp;nbsp;ttt&amp;nbsp;data&amp;nbsp;set)&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data ttt;
format date date9.;
input date :date9.;
cards;
21feb2020
31dec2020
04Mar2021
19mar2021
28Jun2021
;
Run;


PROC SQL noprint;
	select  intnx('day',max(date),1)  into: start_date	   
	from  ttt
;
QUIT;
%put &amp;amp;start_date;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jul 2021 05:23:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-date-with-d-at-end/m-p/754908#M238159</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2021-07-19T05:23:14Z</dc:date>
    </item>
    <item>
      <title>Re: SAS macro date with d at end</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-date-with-d-at-end/m-p/754910#M238160</link>
      <description>&lt;P&gt;Your solution is already ideal: you store the raw numeric value in the macro variable, which is the most easiest to handle in the following code.&lt;/P&gt;
&lt;P&gt;See Maxim 28.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jul 2021 06:14:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-date-with-d-at-end/m-p/754910#M238160</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-07-19T06:14:33Z</dc:date>
    </item>
    <item>
      <title>Re: SAS macro date with d at end</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-date-with-d-at-end/m-p/754963#M238183</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;What is the way to create a SAS date macro variable with d at the end?&lt;/P&gt;
&lt;P&gt;The resulted value in this case should be '&lt;CODE class=" language-sas"&gt;21feb2020'd&amp;nbsp;&amp;nbsp;(one&amp;nbsp;day&amp;nbsp;after&amp;nbsp;max&amp;nbsp;date&amp;nbsp;in&amp;nbsp;ttt&amp;nbsp;data&amp;nbsp;set)&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Don't create macro variables like this, with quotes and a D on the end. Macro variables should not be formatted or human readable (unless they are needed for titles or labels or filenames, in which case they still don't need the quotes or a D on the end)&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jul 2021 11:18:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-date-with-d-at-end/m-p/754963#M238183</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-07-19T11:18:40Z</dc:date>
    </item>
    <item>
      <title>Re: SAS macro date with d at end</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-date-with-d-at-end/m-p/754974#M238188</link>
      <description>&lt;P&gt;It is not really necessary to use INTNX() to add days since SAS stores dates as number of days.&amp;nbsp; Just use normal arithmetic.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The QUOTE() function can be used to add quotes.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data ttt;
  format date date9.;
  input date :date9.;
cards;
21feb2020
31dec2020
04Mar2021
19mar2021
28Jun2021
;

proc sql noprint;
select max(date)+1 
     , cats(quote(put(max(date)+1,date9.)),'d')
  into :start_date trimmed
     , :start_date_human 
  from  ttt
;
quit;

%put &amp;amp;=start_date &amp;amp;=start_date_human ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;START_DATE=22460 START_DATE_HUMAN="29JUN2021"d
&lt;/PRE&gt;
&lt;P&gt;Note that both forms refer to the same day and can be used it most of the same places.&amp;nbsp; The only restriction is you cannot use the human readable date literal with the %EVAL() macro function.&amp;nbsp; You would need to use %SYSEVALF() if you want the macro process to see that string as a date.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jul 2021 12:46:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-date-with-d-at-end/m-p/754974#M238188</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-07-19T12:46:41Z</dc:date>
    </item>
  </channel>
</rss>

