<?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: Convert date format: DATE9.  to 'ddmmmyy'd in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Convert-date-format-DATE9-to-ddmmmyy-d/m-p/635260#M188603</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;wrote:
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The only time you need macro variables to be formatted is when you are creating titles or labels or reports.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;And your CEO will NOT like dates in date9. format. They usually want ddmmyyp10. (German), MMDDYY10. (US), or DDMMYY10. (Australia, NZ, ...), or any other locally used date format.&lt;/P&gt;</description>
    <pubDate>Fri, 27 Mar 2020 10:30:14 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2020-03-27T10:30:14Z</dc:date>
    <item>
      <title>Convert date format: DATE9.  to 'ddmmmyy'd</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-date-format-DATE9-to-ddmmmyy-d/m-p/635253#M188597</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I created this macro:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro date_loop(start,end);&lt;BR /&gt;%let start=%sysfunc(inputn(&amp;amp;start,anydtdte9.));&lt;BR /&gt;%let end=%sysfunc(inputn(&amp;amp;end,anydtdte9.));&lt;BR /&gt;%let dif=%sysfunc(intck(week.2,&amp;amp;start,&amp;amp;end));&lt;BR /&gt;%do i=0 %to &amp;amp;dif;&lt;BR /&gt;%let date=%sysfunc(intnx(week.2,&amp;amp;start,&amp;amp;i,b),date9.);&lt;BR /&gt;%put &amp;amp;date;&lt;BR /&gt;%end;&lt;/P&gt;&lt;P&gt;%mend date_loop;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%date_loop(29sep2019,30mar2020)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But in my skript I need to countinue with the following format: '&lt;EM&gt;ddmmmyyyy&lt;/EM&gt;'d&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried to create the marco above in the format '&lt;EM&gt;ddmmmyyyy&lt;/EM&gt;'d, but it did not work. Has someone an idea how to change the format within the macro or afterwards?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Fri, 27 Mar 2020 10:16:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-date-format-DATE9-to-ddmmmyy-d/m-p/635253#M188597</guid>
      <dc:creator>FLY_FFM</dc:creator>
      <dc:date>2020-03-27T10:16:40Z</dc:date>
    </item>
    <item>
      <title>Re: Convert date format: DATE9.  to 'ddmmmyy'd</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-date-format-DATE9-to-ddmmmyy-d/m-p/635256#M188599</link>
      <description>&lt;P&gt;You do not need that complicated formatting. The raw value (count of days as integer) works just as well, and is much easier to handle.&lt;/P&gt;
&lt;P&gt;If you need a human-readable form, use a proper format like yymmddd10. (which is the ISO-standard); if you need to use the value later as prompt value for a stored process, you only need the datae9. format&amp;nbsp;&lt;EM&gt;without&lt;/EM&gt; the quotes and the trailing "d".&lt;/P&gt;
&lt;P&gt;How do you use the macro variables later in your code?&lt;/P&gt;</description>
      <pubDate>Fri, 27 Mar 2020 10:22:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-date-format-DATE9-to-ddmmmyy-d/m-p/635256#M188599</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-03-27T10:22:58Z</dc:date>
    </item>
    <item>
      <title>Re: Convert date format: DATE9.  to 'ddmmmyy'd</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-date-format-DATE9-to-ddmmmyy-d/m-p/635257#M188600</link>
      <description>You probably want to use format ddmmyyn8.</description>
      <pubDate>Fri, 27 Mar 2020 10:23:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-date-format-DATE9-to-ddmmmyy-d/m-p/635257#M188600</guid>
      <dc:creator>DavePrinsloo</dc:creator>
      <dc:date>2020-03-27T10:23:59Z</dc:date>
    </item>
    <item>
      <title>Re: Convert date format: DATE9.  to 'ddmmmyy'd</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-date-format-DATE9-to-ddmmmyy-d/m-p/635258#M188601</link>
      <description>&lt;P&gt;Normally, I would not repeat an answer given above, but this is important.&amp;nbsp;Macro variables should &lt;FONT color="#FF0000"&gt;not&lt;/FONT&gt; be formatted for any type of logical or arithmetic use.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now I am going to repeat myself!!&amp;nbsp;Macro variables should &lt;FONT color="#FF0000"&gt;not&lt;/FONT&gt; be formatted for any type of logical or arithmetic use.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The only time you need macro variables to be formatted is when you are creating titles or labels or reports or when humans have to read the date. When SAS has to make use of the date, it should be unformatted.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro date_loop(start,end);
    /* Step 1: unformat the start and end dates */
	%let start=%sysevalf("&amp;amp;start"d);
	%let end=%sysevalf("&amp;amp;end"d);
	%put note: start and end are not formatted;
	%put &amp;amp;=start &amp;amp;=end;
	%put;
    /* arithmetic operations work on unformatted macro variables */
	%let dif=%sysfunc(intck(week.2,&amp;amp;start,&amp;amp;end));
	%do i=0 %to &amp;amp;dif;
		%let date=%sysfunc(intnx(week.2,&amp;amp;start,&amp;amp;i,b));
         /* write the results so we can see that the macro is working */
		%put &amp;amp;=i &amp;amp;=date;
		%put DATE FORMATTED %sysfunc(putn(&amp;amp;date,date7.));
	%end;
%mend date_loop;

%date_loop(29sep2019,30mar2020)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Mar 2020 10:59:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-date-format-DATE9-to-ddmmmyy-d/m-p/635258#M188601</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-03-27T10:59:28Z</dc:date>
    </item>
    <item>
      <title>Re: Convert date format: DATE9.  to 'ddmmmyy'd</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-date-format-DATE9-to-ddmmmyy-d/m-p/635259#M188602</link>
      <description>&lt;P&gt;Just to illustrate what I mean:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
do date = today() - 3 to today() + 5;
  output;
end;
format date yymmddd10.;
run;

%let macvar1 = %sysfunc(today());
%let macvar2 = "%sysfunc(today(),date9.)"d;

%put &amp;amp;=macvar1 &amp;amp;=macvar2;

data want1;
set have;
where date = &amp;amp;macvar1;
run;

data want2;
set have;
where date = &amp;amp;macvar2;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The two output datasets are identical.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Mar 2020 10:27:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-date-format-DATE9-to-ddmmmyy-d/m-p/635259#M188602</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-03-27T10:27:31Z</dc:date>
    </item>
    <item>
      <title>Re: Convert date format: DATE9.  to 'ddmmmyy'd</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-date-format-DATE9-to-ddmmmyy-d/m-p/635260#M188603</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;wrote:
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The only time you need macro variables to be formatted is when you are creating titles or labels or reports.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;And your CEO will NOT like dates in date9. format. They usually want ddmmyyp10. (German), MMDDYY10. (US), or DDMMYY10. (Australia, NZ, ...), or any other locally used date format.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Mar 2020 10:30:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-date-format-DATE9-to-ddmmmyy-d/m-p/635260#M188603</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-03-27T10:30:14Z</dc:date>
    </item>
    <item>
      <title>Re: Convert date format: DATE9.  to 'ddmmmyy'd</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-date-format-DATE9-to-ddmmmyy-d/m-p/635470#M188680</link>
      <description>&lt;P&gt;What did you try that did not work?&amp;nbsp; Note that you probably do not want to use single quotes since those will stop the macro processor from working on the strings inside of them.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let date="%sysfunc(intnx(week.2,&amp;amp;start,&amp;amp;i,b),date9.)"d;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 28 Mar 2020 02:11:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-date-format-DATE9-to-ddmmmyy-d/m-p/635470#M188680</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-03-28T02:11:04Z</dc:date>
    </item>
  </channel>
</rss>

