<?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 calculate macro variable from another macro varaiable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/calculate-macro-variable-from-another-macro-varaiable/m-p/614253#M179501</link>
    <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I have a program that user define macro varaible&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;EM&gt;&lt;STRONG&gt;&amp;nbsp;%let CurMon=1907;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to create another macro variable(called SOM)&amp;nbsp; that its value is calculated automatically from the value of &amp;amp;CurMon.&lt;/P&gt;
&lt;P&gt;The value should be start of month and written in format date9.&lt;/P&gt;
&lt;P&gt;So in this case I should get value&lt;FONT color="#FF0000"&gt;&amp;nbsp;'01JUL2019'd&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;other examples:&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;EM&gt;&lt;STRONG&gt;&amp;nbsp;%let CurMon=1908;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;EM&gt;&lt;STRONG&gt;SOM should get value '01AUG2018'd&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;EM&gt;&lt;STRONG&gt;&amp;nbsp;%let CurMon=1902;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;EM&gt;&lt;STRONG&gt;SOM should get value '01FEB2018'd&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What is the way to do it please using&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;%&lt;/SPAN&gt;&lt;EM&gt;SYSFUNC&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp; function please?(or other way)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 29 Dec 2019 07:21:38 GMT</pubDate>
    <dc:creator>Ronein</dc:creator>
    <dc:date>2019-12-29T07:21:38Z</dc:date>
    <item>
      <title>calculate macro variable from another macro varaiable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculate-macro-variable-from-another-macro-varaiable/m-p/614253#M179501</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I have a program that user define macro varaible&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;EM&gt;&lt;STRONG&gt;&amp;nbsp;%let CurMon=1907;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to create another macro variable(called SOM)&amp;nbsp; that its value is calculated automatically from the value of &amp;amp;CurMon.&lt;/P&gt;
&lt;P&gt;The value should be start of month and written in format date9.&lt;/P&gt;
&lt;P&gt;So in this case I should get value&lt;FONT color="#FF0000"&gt;&amp;nbsp;'01JUL2019'd&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;other examples:&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;EM&gt;&lt;STRONG&gt;&amp;nbsp;%let CurMon=1908;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;EM&gt;&lt;STRONG&gt;SOM should get value '01AUG2018'd&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;EM&gt;&lt;STRONG&gt;&amp;nbsp;%let CurMon=1902;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;EM&gt;&lt;STRONG&gt;SOM should get value '01FEB2018'd&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What is the way to do it please using&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;%&lt;/SPAN&gt;&lt;EM&gt;SYSFUNC&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp; function please?(or other way)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 29 Dec 2019 07:21:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculate-macro-variable-from-another-macro-varaiable/m-p/614253#M179501</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2019-12-29T07:21:38Z</dc:date>
    </item>
    <item>
      <title>Re: calculate macro variable from another macro varaiable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculate-macro-variable-from-another-macro-varaiable/m-p/614256#M179503</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I believe in your example, 1908 should refer to 01AUG2019 and not 2018 ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can try this code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let CurMon=1902;
%let SOM = %sysfunc(putn(%sysfunc(MDY(%sysfunc(substr(&amp;amp;CurMon,3,2)),1,%sysfunc(substr(&amp;amp;CurMon,1,2)))),date9.));
%put &amp;amp;SOM;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV class="sasSource"&gt;Log :&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;75 %put &amp;amp;SOM;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;01FEB2019&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 29 Dec 2019 09:04:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculate-macro-variable-from-another-macro-varaiable/m-p/614256#M179503</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2019-12-29T09:04:39Z</dc:date>
    </item>
    <item>
      <title>Re: calculate macro variable from another macro varaiable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculate-macro-variable-from-another-macro-varaiable/m-p/614257#M179504</link>
      <description>&lt;P&gt;Since you obviously want to use it in code, not for display, formatting is not necessary, so you do&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let som=%sysfunc(inputn(20&amp;amp;curmon.01,yymmdd8.));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and get the raw value of the date literal.&lt;/P&gt;</description>
      <pubDate>Sun, 29 Dec 2019 09:04:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculate-macro-variable-from-another-macro-varaiable/m-p/614257#M179504</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-12-29T09:04:38Z</dc:date>
    </item>
  </channel>
</rss>

