<?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 %setdates - Generates SAS date macro variables in multi-formats in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-setdates-Generates-SAS-date-macro-variables-in-multi/m-p/796608#M255639</link>
    <description>On here, in the Knowledge Base is one option.&lt;BR /&gt;&lt;BR /&gt;Example:&lt;BR /&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Demographic-Table-and-Subgroup-Summary-Macro-TABLEN/ta-p/634030" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/Demographic-Table-and-Subgroup-Summary-Macro-TABLEN/ta-p/634030&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Personally, I store mine on Github. &lt;BR /&gt;</description>
    <pubDate>Wed, 16 Feb 2022 16:11:03 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2022-02-16T16:11:03Z</dc:date>
    <item>
      <title>SAS macro %setdates - Generates SAS date macro variables in multi-formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-setdates-Generates-SAS-date-macro-variables-in-multi/m-p/796503#M255599</link>
      <description>&lt;P&gt;Over the years I've seen a variety of useful SAS macros, some more general solution than others, but I don't think there's a central searchable location where they can be posted to.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Q - Is there a recognised/searchable location for general purpose SAS Macros like this one?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-----------------------------------&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;See attached&lt;/STRONG&gt; setdates.sas macro which generates a large number of SAS global macro variables containing (day,wk,month,qtr,year) dates of differing formats (e.g. monyy7), values are generated relative to current date i.e. day0=today, day1=yesterday, mon0=this month, mon1=last month, etc&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example&lt;/P&gt;&lt;P&gt;%put &amp;amp;mon1_start_date9;&lt;/P&gt;&lt;P&gt;resolves to 01JAN2022 (1st of previous month if current month is Feb2022)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%put &amp;amp;mon1_start_date9q;&lt;/P&gt;&lt;P&gt;resolves to '01JAN2022' (the above value in single quotes - useful for pass-thru SQL queries&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;can be overridden using %setdates(date=ddmonyy); this is useful for program testing back and forward in time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Particularly useful when added to the SAS root macro folder and invoked on any SAS session execution. Allows for standardisation across installations with hundreds of users.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;sysdt macro values always refer to system date (not reference date)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&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="davidlogan_0-1645007158798.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/68519i29F120574455B57B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="davidlogan_0-1645007158798.png" alt="davidlogan_0-1645007158798.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;---------------------&lt;/P&gt;&lt;P&gt;Having standardised, predictable, meaningful macro variables names is useful in a number of way&lt;/P&gt;&lt;P&gt;1) looping around dates (see %tmp macro below).&lt;/P&gt;&lt;P&gt;2) Also using for e.g. &amp;amp;mon1_yyyy (which is the yyyy year of the previous month) means not having to write logic to cater for year changes when performing a Dec21 run in Jan22.&amp;nbsp;&lt;/P&gt;&lt;P&gt;3) Avoids users creating (and referencing macro variables with personal preference naming convention like 'mydate' which has little meaning&lt;/P&gt;&lt;P&gt;4) Avoids sometimes convoluted date mathematics to get basic date parameters. When reading someone else code this has to be first deconstructed to understand meaning.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;%macro tmp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; %do i=1 %to 10;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; %put &amp;amp;&amp;amp;mon&amp;amp;i._yyyymm;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; %end;&lt;BR /&gt;%mend;&lt;BR /&gt;%tmp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;202201&lt;BR /&gt;202112&lt;BR /&gt;202111&lt;BR /&gt;202110&lt;BR /&gt;202109&lt;BR /&gt;202108&lt;BR /&gt;202107&lt;BR /&gt;202106&lt;BR /&gt;202105&lt;BR /&gt;202104&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Feb 2022 13:55:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-setdates-Generates-SAS-date-macro-variables-in-multi/m-p/796503#M255599</guid>
      <dc:creator>davidlogan</dc:creator>
      <dc:date>2022-02-16T13:55:40Z</dc:date>
    </item>
    <item>
      <title>Re: SAS macro %setdates - Generates SAS date macro variables in multi-formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-setdates-Generates-SAS-date-macro-variables-in-multi/m-p/796608#M255639</link>
      <description>On here, in the Knowledge Base is one option.&lt;BR /&gt;&lt;BR /&gt;Example:&lt;BR /&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Demographic-Table-and-Subgroup-Summary-Macro-TABLEN/ta-p/634030" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/Demographic-Table-and-Subgroup-Summary-Macro-TABLEN/ta-p/634030&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Personally, I store mine on Github. &lt;BR /&gt;</description>
      <pubDate>Wed, 16 Feb 2022 16:11:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-setdates-Generates-SAS-date-macro-variables-in-multi/m-p/796608#M255639</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-02-16T16:11:03Z</dc:date>
    </item>
    <item>
      <title>Re: SAS macro %setdates - Generates SAS date macro variables in multi-formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-setdates-Generates-SAS-date-macro-variables-in-multi/m-p/796723#M255682</link>
      <description>&lt;P&gt;Q - Is there a recognised/searchable location for general purpose SAS Macros like this one?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'd say no.&amp;nbsp; A lot of individuals and groups have developed and shared their macro libraries either on websites, or github, or via user group papers.&amp;nbsp; But it sounds like you're hoping for something like&amp;nbsp;&lt;A href="https://cran.r-project.org/" target="_blank" rel="noopener"&gt;https://cran.r-project.org/&lt;/A&gt;&amp;nbsp;or &lt;A href="https://pypi.org/" target="_blank" rel="noopener"&gt;https://pypi.org/&lt;/A&gt; where there would be an organization reviewing/curating macros and providing a searchable interface.&amp;nbsp; I don't think there's anything like that for the SAS community.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you spend some time googling you'll find plenty of SAS macro definitions, but the onus is on you to separate the wheat from the chaff.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BTW, if it's possible to edit the subject of a question, I would suggest editing this one, as the subject "&lt;SPAN&gt;SAS macro %setdates - Generates SAS date macro variables in multi-formats"&amp;nbsp;&lt;/SPAN&gt;makes it&amp;nbsp; sound like the question is about a particular macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Feb 2022 22:09:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-setdates-Generates-SAS-date-macro-variables-in-multi/m-p/796723#M255682</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2022-02-16T22:09:08Z</dc:date>
    </item>
    <item>
      <title>Re: SAS macro %setdates - Generates SAS date macro variables in multi-formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-setdates-Generates-SAS-date-macro-variables-in-multi/m-p/796839#M255732</link>
      <description>&lt;P&gt;Hi Quentin,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for this,&amp;nbsp;&lt;SPAN&gt;googling does indeed produce plenty of SAS macro definitions, with the onus on you to separate the wheat from the chaff, hence my question (within the topic) about if there is a recognised repository.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I was posting the macro as a something which other users might find useful, so it wasn't actually a question (despite being in the questions section), although it appears to be the only place I could post something like this&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Feb 2022 11:50:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-setdates-Generates-SAS-date-macro-variables-in-multi/m-p/796839#M255732</guid>
      <dc:creator>davidlogan</dc:creator>
      <dc:date>2022-02-17T11:50:57Z</dc:date>
    </item>
    <item>
      <title>Re: SAS macro %setdates - Generates SAS date macro variables in multi-formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-macro-setdates-Generates-SAS-date-macro-variables-in-multi/m-p/796842#M255734</link>
      <description>&lt;P&gt;Hi Reeza,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This look like a more suitable location, thanks! looks like SAS doesn't consider me experienced enough yet though &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&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="davidlogan_0-1645099036583.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/68575i7CB32729542D4D65/image-size/medium?v=v2&amp;amp;px=400" role="button" title="davidlogan_0-1645099036583.png" alt="davidlogan_0-1645099036583.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Feb 2022 11:58:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-macro-setdates-Generates-SAS-date-macro-variables-in-multi/m-p/796842#M255734</guid>
      <dc:creator>davidlogan</dc:creator>
      <dc:date>2022-02-17T11:58:00Z</dc:date>
    </item>
  </channel>
</rss>

