<?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: macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/macro/m-p/701952#M214981</link>
    <description>&lt;P&gt;Thank you!&lt;/P&gt;</description>
    <pubDate>Fri, 27 Nov 2020 03:20:56 GMT</pubDate>
    <dc:creator>VSht</dc:creator>
    <dc:date>2020-11-27T03:20:56Z</dc:date>
    <item>
      <title>macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro/m-p/701937#M214973</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Some time ago I created a program calculating various dates and then putting them into macros. It worked. Now it does not work. It creates a table, but does not create macro variables. I also noticed that when I run it as a data step with preceding %let assignments it works. As soon as I put it into a macro it does not work.&amp;nbsp;&lt;/P&gt;&lt;P&gt;A shortened version of the code is below or the full program is attached.&lt;/P&gt;&lt;P&gt;Any feedback is much appreciated.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%macro rpt_time(Multiplier=);&lt;BR /&gt;DATA periods;&lt;BR /&gt;*------------------------------------------------------------------------------------;&lt;BR /&gt;* From TODAY();&lt;BR /&gt;format end_dt FYstart_dt pr_end_dt ddmmyy10.;&lt;/P&gt;&lt;P&gt;today = today()-30.5*&amp;amp;Multiplier;&lt;BR /&gt;end_dt = intnx('month',today-30.5*2,0,"E");&lt;BR /&gt;pr_end_dt = intnx('month',today-30.5*2 - 365.25,0,"E");&lt;BR /&gt;&lt;BR /&gt;* PREP;&lt;BR /&gt;year = year(today-30.5*2);&lt;BR /&gt;end_monyy = put(today-30.5*2,monyy.);&lt;BR /&gt;mth = month(today)-2;&lt;BR /&gt;*------------------------------------------------------------------------------------;&lt;BR /&gt;* MONTH;&lt;BR /&gt;current_mth = put(month(today)-2,z2.); /* Current month number - text */&lt;/P&gt;&lt;P&gt;* PERIOD;&lt;BR /&gt;format period_no $2.;&lt;BR /&gt;if mth&amp;gt;6 then period_no=put(mth-6,2.); /* Financial period (month) */&lt;BR /&gt;if mth&amp;lt;7 then period_no=put(mth+6,2.);&lt;/P&gt;&lt;P&gt;* FIN YEAR;&lt;BR /&gt;if mth&amp;gt;6 then do; /* Fin Year: -start- and -end- years */&lt;BR /&gt;FYstart = year;&lt;BR /&gt;FYend = year+1;&lt;BR /&gt;end;&lt;BR /&gt;else if mth&amp;lt;7 then do;&lt;BR /&gt;FYstart = year-1;&lt;BR /&gt;FYend = year;&lt;BR /&gt;end;&lt;BR /&gt;*------------------------------------------------------------------------------------;&lt;/P&gt;&lt;P&gt;* Utilities for naming;&lt;BR /&gt;* YEAR;&lt;BR /&gt;FYend_2 = substr(put(FYend,z4.),3,2);&lt;BR /&gt;fy_prev1 = put(FYend_2-1,z2.);&lt;BR /&gt;fy_prev2 = put(FYend_2-2,z2.);&lt;BR /&gt;fy_prev3 = put(FYend_2-3,z2.);&lt;/P&gt;&lt;P&gt;* FIN YEAR Start Date = 1JulYY;&lt;BR /&gt;FYstart_dt = mdy(7,1,FYstart_2);&lt;/P&gt;&lt;P&gt;* -----------------------------------------------------------------------------------;&lt;/P&gt;&lt;P&gt;*Macro names;&lt;/P&gt;&lt;P&gt;call symputx('current_mth',current_mth); /* Current calendar month - number */ /* supposedly for DiLM, could not find ????????? */&lt;BR /&gt;call symputx('period_no',period_no); /* Current financial period (variable -period- in the dataset) - number */&lt;BR /&gt;call symputx('end_dt',end_dt); /* To subset data in Macros: End of Report period - date numeric */&lt;BR /&gt;call symputx('year',year);&lt;BR /&gt;call symputx('FY6',year);&lt;BR /&gt;call symputx('fy_curr',FYend_2); /* FY value for CHBOI data assembly - 2-char */ /* end*/&lt;BR /&gt;call symputx('fy_prev1',fy_prev1); /* FY value for CHBOI data assembly - 2-char */&lt;BR /&gt;call symputx('fy_prev2',fy_prev2); /* FY value for CHBOI data assembly - 2-char */&lt;BR /&gt;call symputx('fy_prev3',fy_prev3); /* FY value for CHBOI data assembly - 2-char */&lt;BR /&gt;call symputx('FYstart_dt',FYstart_dt); /* Date value for the beginning of FYear - date numeric */&lt;BR /&gt;call symputx('pr_end_dt',pr_end_dt); /* Last year date value for the end of Report period - date numeric - for YTD DiLM */&lt;BR /&gt;RUN;&lt;BR /&gt;%mend;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Nov 2020 01:08:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro/m-p/701937#M214973</guid>
      <dc:creator>VSht</dc:creator>
      <dc:date>2020-11-27T01:08:06Z</dc:date>
    </item>
    <item>
      <title>Re: macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro/m-p/701950#M214980</link>
      <description>&lt;P&gt;This is a SCOPE issue.&amp;nbsp; Your call symputx statement are creating macrovars local to the RPT_TIME macro.&amp;nbsp; They are not creating global macrovars, which is what your subsequent %PUT statements are searching for.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So if you need the macrovars to be global, insert the additional argument&amp;nbsp; &amp;nbsp; ,"G"&amp;nbsp; &amp;nbsp;in each call symputx statement, as in:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;call symputx('quarter_no',quarter_no,'G');  &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 27 Nov 2020 02:55:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro/m-p/701950#M214980</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2020-11-27T02:55:33Z</dc:date>
    </item>
    <item>
      <title>Re: macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro/m-p/701952#M214981</link>
      <description>&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Fri, 27 Nov 2020 03:20:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro/m-p/701952#M214981</guid>
      <dc:creator>VSht</dc:creator>
      <dc:date>2020-11-27T03:20:56Z</dc:date>
    </item>
  </channel>
</rss>

