<?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: Resolving a Macro variable in single and double quotes in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Resolving-a-Macro-variable-in-single-and-double-quotes/m-p/789672#M252739</link>
    <description>&lt;P&gt;Switching " and ' should solve the problem.&lt;/P&gt;</description>
    <pubDate>Wed, 12 Jan 2022 10:39:02 GMT</pubDate>
    <dc:creator>andreas_lds</dc:creator>
    <dc:date>2022-01-12T10:39:02Z</dc:date>
    <item>
      <title>Resolving a Macro variable in single and double quotes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Resolving-a-Macro-variable-in-single-and-double-quotes/m-p/789661#M252726</link>
      <description>&lt;P&gt;I have the following code, where I from SAS send an automatic mail. The problem is that the macro variable does not get resolved, and I believe it has to do with the quotes but I can't figure out how to solve it.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let country. = USA; 

FILENAME Mailbox 
				EMAIL TO=("MyMail@gmail.com")
				SUBJECT="An Example Mail" 
				 replyto="Mail2@gmail.com"				
				;
		DATA _NULL_;
		FILE 	Mailbox 
		type='text/html';
		PUT "Some Random Text" '&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;'
	
		'&amp;lt;a href="MyDirectoryPath\&amp;amp;country."&amp;gt;MyDirectoryPath\&amp;amp;country.&amp;lt;/a&amp;gt;' '&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;'
		;
		RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So the line of code that is the problem is:&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;'&amp;lt;a href="MyDirectoryPath\&amp;amp;country."&amp;gt;MyDirectoryPath\&amp;amp;country.&amp;lt;/a&amp;gt;' '&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;'&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In the mail the following shows up:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;MyDirectoryPath\&amp;amp;country&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;But it should be: MyDirectoryPath\USA, i.e. the macro variable should resolve.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Any suggestions?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jan 2022 09:33:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Resolving-a-Macro-variable-in-single-and-double-quotes/m-p/789661#M252726</guid>
      <dc:creator>SasStatistics</dc:creator>
      <dc:date>2022-01-12T09:33:47Z</dc:date>
    </item>
    <item>
      <title>Re: Resolving a Macro variable in single and double quotes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Resolving-a-Macro-variable-in-single-and-double-quotes/m-p/789662#M252727</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/381436"&gt;@SasStatistics&lt;/a&gt;.,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The &lt;FONT face="courier new,courier"&gt;%let&lt;/FONT&gt; statement has a "." after "country", so I removed it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The following code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let country = USA;

data _null_;
   text = cat("Some Random Text"
             ,'&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;'
             ,'&amp;lt;a href='
             ,quote("MyDirectoryPath\&amp;amp;country.")
             ,"&amp;gt;MyDirectoryPath\&amp;amp;country.&amp;lt;/a&amp;gt;' '&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;'"
             );
   put text;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;produces:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Some Random Text&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;a href="MyDirectoryPath\USA"&amp;gt;MyDirectoryPath\USA&amp;lt;/a&amp;gt;' '&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;'&lt;/PRE&gt;
&lt;P&gt;Is that what you're looking for?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards,&lt;/P&gt;
&lt;P&gt;Amir.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jan 2022 09:56:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Resolving-a-Macro-variable-in-single-and-double-quotes/m-p/789662#M252727</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2022-01-12T09:56:31Z</dc:date>
    </item>
    <item>
      <title>Re: Resolving a Macro variable in single and double quotes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Resolving-a-Macro-variable-in-single-and-double-quotes/m-p/789670#M252737</link>
      <description>&lt;P&gt;Build the string using single quotes to mask double quotes, and double quotes around macro variables:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let country = USA;

data _null_;
string =
  'Some Random Text&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;a href="' !!
  "MyDirectoryPath\&amp;amp;country." !!
  '"&amp;gt;' !!
  "MyDirectoryPath\&amp;amp;country.&amp;lt;/a&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;"
;
put string;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 12 Jan 2022 10:32:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Resolving-a-Macro-variable-in-single-and-double-quotes/m-p/789670#M252737</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-01-12T10:32:51Z</dc:date>
    </item>
    <item>
      <title>Re: Resolving a Macro variable in single and double quotes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Resolving-a-Macro-variable-in-single-and-double-quotes/m-p/789672#M252739</link>
      <description>&lt;P&gt;Switching " and ' should solve the problem.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jan 2022 10:39:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Resolving-a-Macro-variable-in-single-and-double-quotes/m-p/789672#M252739</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2022-01-12T10:39:02Z</dc:date>
    </item>
    <item>
      <title>Re: Resolving a Macro variable in single and double quotes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Resolving-a-Macro-variable-in-single-and-double-quotes/m-p/789686#M252742</link>
      <description>Do you know why this is so? Is it some general principle?</description>
      <pubDate>Wed, 12 Jan 2022 12:35:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Resolving-a-Macro-variable-in-single-and-double-quotes/m-p/789686#M252742</guid>
      <dc:creator>SasStatistics</dc:creator>
      <dc:date>2022-01-12T12:35:14Z</dc:date>
    </item>
    <item>
      <title>Re: Resolving a Macro variable in single and double quotes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Resolving-a-Macro-variable-in-single-and-double-quotes/m-p/789687#M252743</link>
      <description>The solution was: "Switching " and ' should solve the problem."</description>
      <pubDate>Wed, 12 Jan 2022 12:35:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Resolving-a-Macro-variable-in-single-and-double-quotes/m-p/789687#M252743</guid>
      <dc:creator>SasStatistics</dc:creator>
      <dc:date>2022-01-12T12:35:41Z</dc:date>
    </item>
  </channel>
</rss>

