<?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: Basic Libname Macro Issue in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Basic-Libname-Macro-Issue/m-p/343331#M78813</link>
    <description>&lt;P&gt;Macro triggers (% and &amp;amp;) are not resolved when enclosed in single quotes. Use double quotes instead.&lt;/P&gt;</description>
    <pubDate>Wed, 22 Mar 2017 15:27:17 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2017-03-22T15:27:17Z</dc:date>
    <item>
      <title>Basic Libname Macro Issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Basic-Libname-Macro-Issue/m-p/343326#M78812</link>
      <description>&lt;P&gt;&lt;U&gt;Hi everyone,&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to make myself use macros more and have come up with an error in a basic macro that will assign a libname by year and file location. See below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro yearc;

%let year= 2012 2013 2014 2015;

	%do i=1 %to 4;
		%let yearold=%scan(&amp;amp;year, &amp;amp;i);

			libname old&amp;amp;yearold '\\cdc.gov\project\CCID_NCIRD_DBD_MVPDB\Epi Team\Pertussis Epi\EIP\Enhanced Surveillance Project\Data\Formatted Data\Historic Datasets\Static_1999_&amp;amp;yearold_Dataset';

		%end;
	%mend yearc;
%yearc;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The macro revolves the first &amp;amp;yearold varible in the libname statement creating the libarary, but it doesn't work with the macro variable in the libname statement for the file pathway. It just resolves to C:\\My Documents\Old_Datasets\Finalized_1999_&amp;amp;yearold._Dataset. Am I missing something? Any suggestions would be much appreciated!&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Mar 2017 15:24:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Basic-Libname-Macro-Issue/m-p/343326#M78812</guid>
      <dc:creator>cc1986</dc:creator>
      <dc:date>2017-03-22T15:24:46Z</dc:date>
    </item>
    <item>
      <title>Re: Basic Libname Macro Issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Basic-Libname-Macro-Issue/m-p/343331#M78813</link>
      <description>&lt;P&gt;Macro triggers (% and &amp;amp;) are not resolved when enclosed in single quotes. Use double quotes instead.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Mar 2017 15:27:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Basic-Libname-Macro-Issue/m-p/343331#M78813</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-03-22T15:27:17Z</dc:date>
    </item>
    <item>
      <title>Re: Basic Libname Macro Issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Basic-Libname-Macro-Issue/m-p/343340#M78815</link>
      <description>&lt;P&gt;Macro variables do not resolve inside single quotes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token statement"&gt;libname&lt;/SPAN&gt; old&lt;SPAN class="token operator"&gt;&amp;amp;&lt;/SPAN&gt;yearold "&lt;SPAN class="token string"&gt;\\cdc.gov\project\CCID_NCIRD_DBD_MVPDB\Epi Team\Pertussis Epi\EIP\Enhanced Surveillance Project\Data\Formatted Data\Historic Datasets\Static_1999_&amp;amp;yearold&lt;FONT color="#ff0000" size="4"&gt;&lt;STRONG&gt;.&lt;/STRONG&gt;&lt;/FONT&gt;_Dataset"&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token string"&gt;&lt;SPAN class="token punctuation"&gt;Also when using a macro variable in a compound you need to have the dot operator to tell SAS to concatenate the following text.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token string"&gt;&lt;SPAN class="token punctuation"&gt;&amp;amp;yearold_dataset would be considered the whole macro variable name.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token string"&gt;&lt;SPAN class="token punctuation"&gt;See what result you get with:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token string"&gt;&lt;SPAN class="token punctuation"&gt;%put &amp;amp;yearold_dataset;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token string"&gt;&lt;SPAN class="token punctuation"&gt;to get familiar with the error message.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token string"&gt;&lt;SPAN class="token punctuation"&gt;Also look at this and see that the scan, at least in your specific example is not needed.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;%macro dummy;
%do YearOld = 2012 %to 2014;

	%put	libname old&amp;amp;yearold;

%end;
%mend dummy;
%dummy;
&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Mar 2017 15:34:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Basic-Libname-Macro-Issue/m-p/343340#M78815</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-03-22T15:34:26Z</dc:date>
    </item>
    <item>
      <title>Re: Basic Libname Macro Issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Basic-Libname-Macro-Issue/m-p/343405#M78835</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you both so much for your help! I guess I tried replacing the double-quotes and adding a period, but not at the same time. I will put this in my memory bank for the next macro I do. I'm &lt;EM&gt;slowly&lt;/EM&gt; learning!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;cc1986&lt;/P&gt;</description>
      <pubDate>Wed, 22 Mar 2017 16:51:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Basic-Libname-Macro-Issue/m-p/343405#M78835</guid>
      <dc:creator>cc1986</dc:creator>
      <dc:date>2017-03-22T16:51:16Z</dc:date>
    </item>
    <item>
      <title>Re: Basic Libname Macro Issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Basic-Libname-Macro-Issue/m-p/343412#M78836</link>
      <description>&lt;P&gt;A very helpful diagnostic with macros are the system options MPRINT SYMBOLGEN and MLOGIC.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;They show the generated code, the resolution of macro variables and the results of macro logic (%if and similar) statements.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Options mprint symbolgen;&amp;nbsp; /*turn on the option */&lt;/P&gt;
&lt;P&gt;%macrocall&lt;/P&gt;
&lt;P&gt;Options nomprint nosymbolgen; /*&amp;nbsp;to turn off*/&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Will provide a bit more information in the log to diagnose many issues.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Mar 2017 17:04:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Basic-Libname-Macro-Issue/m-p/343412#M78836</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-03-22T17:04:07Z</dc:date>
    </item>
  </channel>
</rss>

