<?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 Two Macros in Data x; Set y; Statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Two-Macros-in-Data-x-Set-y-Statement/m-p/437330#M108873</link>
    <description>&lt;P&gt;Is there something I need to do to use two macro variables in a row dynamically?&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;%let yearVar = 1617;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;%let yearTypeVar = 'S';&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;This works:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;data year&amp;amp;yearVar; set work.combined2;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Using the second variable causes&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;data year&amp;amp;yearVar&amp;amp;yearTypeVar; set work.combined2;&lt;BR /&gt;run;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;ERROR: User does not have appropriate authorization level for library WC000001.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 14 Feb 2018 20:47:10 GMT</pubDate>
    <dc:creator>DavidPhillips2</dc:creator>
    <dc:date>2018-02-14T20:47:10Z</dc:date>
    <item>
      <title>Two Macros in Data x; Set y; Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Two-Macros-in-Data-x-Set-y-Statement/m-p/437330#M108873</link>
      <description>&lt;P&gt;Is there something I need to do to use two macro variables in a row dynamically?&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;%let yearVar = 1617;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;%let yearTypeVar = 'S';&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;This works:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;data year&amp;amp;yearVar; set work.combined2;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Using the second variable causes&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;data year&amp;amp;yearVar&amp;amp;yearTypeVar; set work.combined2;&lt;BR /&gt;run;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;ERROR: User does not have appropriate authorization level for library WC000001.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Feb 2018 20:47:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Two-Macros-in-Data-x-Set-y-Statement/m-p/437330#M108873</guid>
      <dc:creator>DavidPhillips2</dc:creator>
      <dc:date>2018-02-14T20:47:10Z</dc:date>
    </item>
    <item>
      <title>Re: Two Macros in Data x; Set y; Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Two-Macros-in-Data-x-Set-y-Statement/m-p/437334#M108874</link>
      <description>&lt;P&gt;Resolving the macro variables shows that your proposed data set name is illegal:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data year1617'S'; set work.combined2;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you intended that your data set name should be:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;year1617S&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The usual way to achieve that would be to omit the quotes when assigning a value:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;%let yearTypeVar = S;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Then in sections of the code where you need quotes, refer to the macro variable within double-quotes:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;"&amp;amp;yearTypeVar"&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Feb 2018 20:55:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Two-Macros-in-Data-x-Set-y-Statement/m-p/437334#M108874</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-02-14T20:55:49Z</dc:date>
    </item>
    <item>
      <title>Re: Two Macros in Data x; Set y; Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Two-Macros-in-Data-x-Set-y-Statement/m-p/437344#M108876</link>
      <description>&lt;P&gt;&lt;SPAN&gt;data year&amp;amp;yearVar&amp;amp;yearTypeVar;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;How does SAS know where the macro variable ends?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Make sure to end it with a period when using them in text or back to back.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;data year&amp;amp;yearVar.&amp;amp;yearTypeVar.;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;In general, using a period at the end always is going to lead to less errors than leaving it out.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;PS. Yes, I know people on here will disagree with that last statement &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Feb 2018 21:00:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Two-Macros-in-Data-x-Set-y-Statement/m-p/437344#M108876</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-02-14T21:00:21Z</dc:date>
    </item>
    <item>
      <title>Re: Two Macros in Data x; Set y; Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Two-Macros-in-Data-x-Set-y-Statement/m-p/437351#M108878</link>
      <description>&lt;P&gt;There's nothing wrong with adding a period at the end of macro variable names.&amp;nbsp; However, it's not the source of the problem here, and it won't change the error condition in this particular case.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Feb 2018 21:04:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Two-Macros-in-Data-x-Set-y-Statement/m-p/437351#M108878</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-02-14T21:04:49Z</dc:date>
    </item>
  </channel>
</rss>

