<?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 Unsure how to code a better macro for the requirements? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Unsure-how-to-code-a-better-macro-for-the-requirements/m-p/303208#M270451</link>
    <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a SAS program that i run monthly where i have to pull data from dozens of files that are also updated monthly. The issue i have is with the date macros in the program. They work but i would like to make things more efficient for someone that is going to be taking on the process. My question is, is there a way to have a macro use the first day of the prior month to the time i run the report? Also, have one use the last day of the prior month to when i am running the report? Currently, i open the program and update a few areas with the next month in line prior to running the reports. Because the person who is going to take on this job does not understand coding, i would like to make it so they only have to run the program for now as they learn. I am also not en expert but know enough to be dangerous.&amp;nbsp;below is an example of what i am talking about.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example macro:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let begin_dt = '01Sep2015'd;&lt;/P&gt;&lt;P&gt;%let end_dt = '31sep2016'd;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When November rolls around i will update a few things like this to show the previous month/day combinations.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example for November:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let begin_dt = '01Oct2015'd;&lt;/P&gt;&lt;P&gt;%let end_dt = '31Oct2016'd;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would prefer to set things up so that this does not have to be updated each month and rather program so that it will&amp;nbsp;use the correct inforation on its own when the program is run.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone have an idea of how to set this up? I have tried a few things but have not successfully made this work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you all!&lt;/P&gt;</description>
    <pubDate>Fri, 07 Oct 2016 16:23:45 GMT</pubDate>
    <dc:creator>SiTheBSA</dc:creator>
    <dc:date>2016-10-07T16:23:45Z</dc:date>
    <item>
      <title>Unsure how to code a better macro for the requirements?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unsure-how-to-code-a-better-macro-for-the-requirements/m-p/303208#M270451</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a SAS program that i run monthly where i have to pull data from dozens of files that are also updated monthly. The issue i have is with the date macros in the program. They work but i would like to make things more efficient for someone that is going to be taking on the process. My question is, is there a way to have a macro use the first day of the prior month to the time i run the report? Also, have one use the last day of the prior month to when i am running the report? Currently, i open the program and update a few areas with the next month in line prior to running the reports. Because the person who is going to take on this job does not understand coding, i would like to make it so they only have to run the program for now as they learn. I am also not en expert but know enough to be dangerous.&amp;nbsp;below is an example of what i am talking about.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example macro:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let begin_dt = '01Sep2015'd;&lt;/P&gt;&lt;P&gt;%let end_dt = '31sep2016'd;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When November rolls around i will update a few things like this to show the previous month/day combinations.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example for November:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let begin_dt = '01Oct2015'd;&lt;/P&gt;&lt;P&gt;%let end_dt = '31Oct2016'd;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would prefer to set things up so that this does not have to be updated each month and rather program so that it will&amp;nbsp;use the correct inforation on its own when the program is run.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone have an idea of how to set this up? I have tried a few things but have not successfully made this work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you all!&lt;/P&gt;</description>
      <pubDate>Fri, 07 Oct 2016 16:23:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unsure-how-to-code-a-better-macro-for-the-requirements/m-p/303208#M270451</guid>
      <dc:creator>SiTheBSA</dc:creator>
      <dc:date>2016-10-07T16:23:45Z</dc:date>
    </item>
    <item>
      <title>Re: Unsure how to code a better macro for the requirements?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unsure-how-to-code-a-better-macro-for-the-requirements/m-p/303215#M270452</link>
      <description>&lt;P&gt;If the program involved always is run to refer to the previous month from the date of execution&amp;nbsp;then you could stick this code inside the macro&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
   sdate= intnx('month',today(),-1,'B');
   edate= intnx('month',today(),-1,'E');
   call symputx('begin_dt',sdate);
   call symputx('end_dt',edate);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that the values will be the numeric version of the SAS date value which should match for your uses UNLESS you are printing those directly in titles or such.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Oct 2016 16:53:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unsure-how-to-code-a-better-macro-for-the-requirements/m-p/303215#M270452</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-10-07T16:53:08Z</dc:date>
    </item>
  </channel>
</rss>

