<?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: how do I create dynamic dates with certain date format using a macro? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-do-I-create-dynamic-dates-with-certain-date-format-using-a/m-p/690178#M209931</link>
    <description>You can replace it with the unformatted macro variable, it'll still work fine. Try it if you don't believe us. &lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Thu, 08 Oct 2020 20:22:29 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2020-10-08T20:22:29Z</dc:date>
    <item>
      <title>how do I create dynamic dates with certain date format using a macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-do-I-create-dynamic-dates-with-certain-date-format-using-a/m-p/690150#M209909</link>
      <description>&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;I have the following code below that has a hard-coded BeginDt and macro to create EndDate3, both of which are later used in my program and need to be in 'ddmmmyyyy'd format:&lt;/P&gt;&lt;P&gt;%let BeginDt = '01SEP2015'd;&lt;/P&gt;&lt;P&gt;%let Enddt = %sysfunc(today(),date9.);&lt;BR /&gt;%let Enddt2 ="&amp;amp;Enddt"d;&lt;BR /&gt;%let Enddt3=%sysfunc(tranwrd(&amp;amp;Enddt2,%str(%"),%str(%')));&lt;BR /&gt;%put &amp;amp;Enddt3;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to modify the code, so the BeginDate is also dynamic based on a certain condition. The condition is that if EndDt3 is less that 01Sep(current year) then Startdate should be 01Sep(current year minus 5). Otherwise, if EndDt3 is greater or equal to 01Sep(current year) then StartDate should be 01Sep(current year minus 4).&amp;nbsp;Ultimately, I need StartDate macro variable to look like '01sep2015'd (depending on a condition).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have this code below and it's not working as it's not converting macro characters into date values:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;%let Enddt = %sysfunc(today(),date9.);&lt;BR /&gt;%let Enddt2 ="&amp;amp;Enddt"d;&lt;BR /&gt;%let Enddt3=%sysfunc(tranwrd(&amp;amp;Enddt2,%str(%"),%str(%')));&lt;BR /&gt;%let curr_year=%sysfunc(year(%sysfunc(date())));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if &amp;amp;Enddt3 &amp;lt; '01sep&amp;amp;curr_year'd then start='01sep(&amp;amp;curr_year-5)'d;&lt;BR /&gt;else if &amp;amp;Enddt3 &amp;gt;= '01sep&amp;amp;curr_year'd then start='01sep(&amp;amp;curr_year-4)'d;&lt;BR /&gt;%let StartDt=start;&lt;BR /&gt;%put &amp;amp;StartDt;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any suggestions of how to solve this would be greatly appreciated.&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 08 Oct 2020 19:23:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-do-I-create-dynamic-dates-with-certain-date-format-using-a/m-p/690150#M209909</guid>
      <dc:creator>Bluebonnet16</dc:creator>
      <dc:date>2020-10-08T19:23:44Z</dc:date>
    </item>
    <item>
      <title>Re: how do I create dynamic dates with certain date format using a macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-do-I-create-dynamic-dates-with-certain-date-format-using-a/m-p/690156#M209913</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data demo;

if month(today()) &amp;gt;= 9 then 
year_start = year(Today()) - 5;
else year_Start = year(Today()) - 4;

date_start = mdy(9, 1, year_start);
date_end = today();


call symputx('date_end', catt(quote(put(date_end, date9.)), 'd'));
call symputx('date_start', catt(quote(put(date_start, date9.)), 'd'));

run;

%put &amp;amp;date_end.;
%put &amp;amp;date_start.;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 08 Oct 2020 19:37:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-do-I-create-dynamic-dates-with-certain-date-format-using-a/m-p/690156#M209913</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-10-08T19:37:23Z</dc:date>
    </item>
    <item>
      <title>Re: how do I create dynamic dates with certain date format using a macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-do-I-create-dynamic-dates-with-certain-date-format-using-a/m-p/690163#M209916</link>
      <description>&lt;P&gt;Thank you!&amp;nbsp;The code is&amp;nbsp;easy to understand and works. But the final %put macros are in "01SEP2015"d, but that I can fix! Thank you SO much!!!&lt;/P&gt;</description>
      <pubDate>Thu, 08 Oct 2020 19:56:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-do-I-create-dynamic-dates-with-certain-date-format-using-a/m-p/690163#M209916</guid>
      <dc:creator>Bluebonnet16</dc:creator>
      <dc:date>2020-10-08T19:56:28Z</dc:date>
    </item>
    <item>
      <title>Re: how do I create dynamic dates with certain date format using a macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-do-I-create-dynamic-dates-with-certain-date-format-using-a/m-p/690166#M209919</link>
      <description>&lt;P&gt;Your coding would be so much easier if you just didn't format the macro variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let Enddt = %sysfunc(today());&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and then you wouldn't have to go through the trouble to surround it in quotes, and later change the quotes to double-quotes, and you wouldn't have to put the letter D after the quotes, and this simplicity carries through the entire code. &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Maxims-of-Maximally-Efficient-SAS-Programmers/ta-p/352068" target="_self"&gt;Maxim 28&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Oct 2020 20:04:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-do-I-create-dynamic-dates-with-certain-date-format-using-a/m-p/690166#M209919</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-10-08T20:04:21Z</dc:date>
    </item>
    <item>
      <title>Re: how do I create dynamic dates with certain date format using a macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-do-I-create-dynamic-dates-with-certain-date-format-using-a/m-p/690172#M209925</link>
      <description>That is what gets created. Check the log.</description>
      <pubDate>Thu, 08 Oct 2020 20:13:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-do-I-create-dynamic-dates-with-certain-date-format-using-a/m-p/690172#M209925</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-10-08T20:13:04Z</dc:date>
    </item>
    <item>
      <title>Re: how do I create dynamic dates with certain date format using a macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-do-I-create-dynamic-dates-with-certain-date-format-using-a/m-p/690175#M209928</link>
      <description>&lt;P&gt;yes, it would have been easier, but my program is using these 2 date macros to pull the data from other datasets and just works in 'ddmmmyyyy'd format.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Oct 2020 20:18:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-do-I-create-dynamic-dates-with-certain-date-format-using-a/m-p/690175#M209928</guid>
      <dc:creator>Bluebonnet16</dc:creator>
      <dc:date>2020-10-08T20:18:02Z</dc:date>
    </item>
    <item>
      <title>Re: how do I create dynamic dates with certain date format using a macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-do-I-create-dynamic-dates-with-certain-date-format-using-a/m-p/690178#M209931</link>
      <description>You can replace it with the unformatted macro variable, it'll still work fine. Try it if you don't believe us. &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 08 Oct 2020 20:22:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-do-I-create-dynamic-dates-with-certain-date-format-using-a/m-p/690178#M209931</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-10-08T20:22:29Z</dc:date>
    </item>
    <item>
      <title>Re: how do I create dynamic dates with certain date format using a macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-do-I-create-dynamic-dates-with-certain-date-format-using-a/m-p/690198#M209947</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/240829"&gt;@Bluebonnet16&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;yes, it would have been easier, but my program is using these 2 date macros to pull the data from other datasets and just works in 'ddmmmyyyy'd format.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Just because you receive the data in a certain form doesn't mean you have to choose the most difficult way to continue the programming.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Oct 2020 20:58:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-do-I-create-dynamic-dates-with-certain-date-format-using-a/m-p/690198#M209947</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-10-08T20:58:09Z</dc:date>
    </item>
    <item>
      <title>Re: how do I create dynamic dates with certain date format using a macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-do-I-create-dynamic-dates-with-certain-date-format-using-a/m-p/690202#M209951</link>
      <description>And you're right! I'll work on simplifying my code. Thank you for the feedback!!&lt;BR /&gt;</description>
      <pubDate>Thu, 08 Oct 2020 21:03:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-do-I-create-dynamic-dates-with-certain-date-format-using-a/m-p/690202#M209951</guid>
      <dc:creator>Bluebonnet16</dc:creator>
      <dc:date>2020-10-08T21:03:13Z</dc:date>
    </item>
  </channel>
</rss>

