<?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: Let macros like this %let year1 = %eval(&amp;amp;year3-2); in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Let-macros-like-this-let-year1-eval-amp-year3-2/m-p/801409#M315399</link>
    <description>Thanks, I think this works.&lt;BR /&gt;&lt;BR /&gt;Gene</description>
    <pubDate>Thu, 10 Mar 2022 18:05:10 GMT</pubDate>
    <dc:creator>geneshackman</dc:creator>
    <dc:date>2022-03-10T18:05:10Z</dc:date>
    <item>
      <title>Let macros like this %let year1 = %eval(&amp;year3-2);</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Let-macros-like-this-let-year1-eval-amp-year3-2/m-p/801392#M315391</link>
      <description>&lt;P&gt;I all. I have a couple of questions about macros.&lt;/P&gt;
&lt;P&gt;Does this&lt;/P&gt;
&lt;P&gt;%let year3 = 2019;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let year1 = %eval(&amp;amp;year3-2);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do the same as this?&lt;/P&gt;
&lt;P&gt;%let year1 = 2017;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let year3 = %eval(&amp;amp;year1+2);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another let statement in the program is this&lt;/P&gt;
&lt;P&gt;%let folderyear = 20172019;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How to change the "20172019" to macro&lt;/P&gt;
&lt;P&gt;I’d like to change this to macro, using year1year3 instead?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and the program also has these lines&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;libname pop "\\datafolder\PopulationData";&lt;/P&gt;
&lt;P&gt;set pop.pop2009_2018_agelevel (where=(&amp;amp;year1 le year le &amp;amp;year3) );&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How do i change "pop2009_2018_agelevel" to also use macros, so it will use year3 and year3-9, so in this case it would use a file named pop2010_2019_agelevel?&lt;/P&gt;
&lt;P&gt;I think i'd need another let statement at the top of the program, like&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let year9 =&amp;nbsp;%eval(&amp;amp;year3-9);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Mar 2022 16:47:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Let-macros-like-this-let-year1-eval-amp-year3-2/m-p/801392#M315391</guid>
      <dc:creator>geneshackman</dc:creator>
      <dc:date>2022-03-10T16:47:23Z</dc:date>
    </item>
    <item>
      <title>Re: Let macros like this %let year1 = %eval(&amp;year3-2);</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Let-macros-like-this-let-year1-eval-amp-year3-2/m-p/801394#M315392</link>
      <description>&lt;P&gt;You don't seem to be calling any macros in that code.&amp;nbsp; A call to a macro would look like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%mymacro(parm1=1,parm2=abc)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You are just working with macro variables.&amp;nbsp; They are two different things.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It looks like for your application you just want to extract parts of the macro variable value.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%SUBSTR() is a good function to use for that.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let folderyear = 20172019;
%let year1=%substr(&amp;amp;folderyear,1,4);
%let year2=%substr(&amp;amp;folderyear,5);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now that you have the two 4 digit strings in two macro variables you can use them to build your dataset name and WHERE= condition.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;set&amp;nbsp;pop.pop&amp;amp;year1._&amp;amp;year2._agelevel(where=(year&amp;nbsp;between&amp;nbsp;&amp;amp;year1.&amp;nbsp;and&amp;nbsp;&amp;amp;year2.));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Notice the periods after the macro variable names in building the dataset name.&amp;nbsp; That is critical for this to work.&lt;/P&gt;
&lt;P&gt;Without them you would be looking for macro variables named YEAR1_ and YEAR2_AGELEVEL instead of YEAR1 and YEAR2.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Mar 2022 16:59:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Let-macros-like-this-let-year1-eval-amp-year3-2/m-p/801394#M315392</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-03-10T16:59:39Z</dc:date>
    </item>
    <item>
      <title>Re: Let macros like this %let year1 = %eval(&amp;year3-2);</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Let-macros-like-this-let-year1-eval-amp-year3-2/m-p/801409#M315399</link>
      <description>Thanks, I think this works.&lt;BR /&gt;&lt;BR /&gt;Gene</description>
      <pubDate>Thu, 10 Mar 2022 18:05:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Let-macros-like-this-let-year1-eval-amp-year3-2/m-p/801409#M315399</guid>
      <dc:creator>geneshackman</dc:creator>
      <dc:date>2022-03-10T18:05:10Z</dc:date>
    </item>
  </channel>
</rss>

