<?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: Macro Resolution - Using quotation marks or not in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-Resolution-Using-quotation-marks-or-not/m-p/751739#M236684</link>
    <description>&lt;P&gt;The reason you might want to include quote characters in the strings you are comparing to protect against values to look like operators to the implied %EVAL() function call you are generating.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example when testing two letter state abbreviation codes.&amp;nbsp; Try testing for the code for Oregon.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The reason the last test is false is pretty obvious, the first character of the strings being compared are different.&amp;nbsp;&lt;FONT face="courier new,courier" size="5"&gt; "&lt;/FONT&gt; does not equal &lt;FONT face="courier new,courier" size="5"&gt;'&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 02 Jul 2021 14:02:55 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2021-07-02T14:02:55Z</dc:date>
    <item>
      <title>Macro Resolution - Using quotation marks or not</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Resolution-Using-quotation-marks-or-not/m-p/751654#M236646</link>
      <description>&lt;P&gt;Assume we have the following two alternatives:&amp;nbsp;&lt;BR /&gt;Alternative 1 (Please note the comment with the dot, is this better practice to use?):&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let country = USA; 

%if "&amp;amp;country" = "USA" %then %do;  * Is it better to write: %if "&amp;amp;country." = "USA" %then %do ?; 
	%put Note: right; 
%end; 
%else %do; 
	%put Note: Wrong; 
%end; 
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Alternative 2 (Please note the comment with the dot, is this better practice to use?):&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let country = USA; 

%if &amp;amp;country = USA %then %do; * Is it better to write: %if &amp;amp;country. = USA %then %do ?;
	%put Note: right; 
%end; 
%else %do; 
	%put Note: Wrong; 
%end; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Both alternatives work but it seems to me like the first alternative "should be preferred" since it is text (USA) we are dealing with? Any opinions on this?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Finally, why would the following produce "wrong"?&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let country = USA; 

%if "&amp;amp;country" = 'USA' %then %do; 
	%put Note: right; 
%end; 
%else %do; 
	%put Note: Wrong; 
%end; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;Regarding the comments, is it better practice to use a dot?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jul 2021 08:41:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Resolution-Using-quotation-marks-or-not/m-p/751654#M236646</guid>
      <dc:creator>SasStatistics</dc:creator>
      <dc:date>2021-07-02T08:41:28Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Resolution - Using quotation marks or not</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Resolution-Using-quotation-marks-or-not/m-p/751658#M236649</link>
      <description>&lt;P&gt;It is never wrong to use the dot, so it is recommended, especially for beginners, to use it. It also makes macro references more visible in the Enhanced Editor.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since the macro processor knows only one "data type" (text), quotes are not necessary; in fact, they become part of the text, and that is why your comparison of single vs. double quotes will always return false.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jul 2021 09:27:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Resolution-Using-quotation-marks-or-not/m-p/751658#M236649</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-07-02T09:27:32Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Resolution - Using quotation marks or not</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Resolution-Using-quotation-marks-or-not/m-p/751677#M236660</link>
      <description>&lt;P&gt;If I understand it correctly, text is NOT the same as string?&lt;BR /&gt;&lt;BR /&gt;Example 1 (Text): This is some text &lt;BR /&gt;Example 2 (String): "This is a string"&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jul 2021 10:37:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Resolution-Using-quotation-marks-or-not/m-p/751677#M236660</guid>
      <dc:creator>SasStatistics</dc:creator>
      <dc:date>2021-07-02T10:37:01Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Resolution - Using quotation marks or not</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Resolution-Using-quotation-marks-or-not/m-p/751691#M236667</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/381436"&gt;@SasStatistics&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;If I understand it correctly, text is NOT the same as string?&lt;BR /&gt;&lt;BR /&gt;Example 1 (Text): This is some text &lt;BR /&gt;Example 2 (String): "This is a string"&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That's not it. Macro variables are always text. You do not need to use quotes around the value of macro variables, because they are always text.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you put macro variables in quotes, then the quotes are part of the macro variable value. In the code below &amp;amp;a1 is a character string that has six characters, a double-quote, then a capital T and then an e and then an x and then a t and then a double quote. In the code below &amp;amp;a2 is a character string of four characters, and none of the four characters is a double quote.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro nothing;

%let a1 = "Text";
%let a2 = Text;

%if &amp;amp;a1=Text %then %put TRUE; %else %put FALSE;
%if &amp;amp;a2=Text %then %put TRUE; %else %put FALSE;
%if &amp;amp;a1=&amp;amp;a2 %then %put TRUE; %else %put FALSE;
%mend;

%nothing&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;As you can see in the results, &amp;amp;a1 does not equal Text because &amp;amp;a1 has quotes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DO NOT PUT QUOTES around the values of your macro variable. Generally, quotes are simply not need when defining or evaluating macro variables.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jul 2021 12:12:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Resolution-Using-quotation-marks-or-not/m-p/751691#M236667</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-07-02T12:12:35Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Resolution - Using quotation marks or not</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Resolution-Using-quotation-marks-or-not/m-p/751737#M236683</link>
      <description>&lt;P&gt;For the macro processor, both are just text, with the second one containing quotes.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jul 2021 13:54:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Resolution-Using-quotation-marks-or-not/m-p/751737#M236683</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-07-02T13:54:55Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Resolution - Using quotation marks or not</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Resolution-Using-quotation-marks-or-not/m-p/751739#M236684</link>
      <description>&lt;P&gt;The reason you might want to include quote characters in the strings you are comparing to protect against values to look like operators to the implied %EVAL() function call you are generating.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example when testing two letter state abbreviation codes.&amp;nbsp; Try testing for the code for Oregon.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The reason the last test is false is pretty obvious, the first character of the strings being compared are different.&amp;nbsp;&lt;FONT face="courier new,courier" size="5"&gt; "&lt;/FONT&gt; does not equal &lt;FONT face="courier new,courier" size="5"&gt;'&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jul 2021 14:02:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Resolution-Using-quotation-marks-or-not/m-p/751739#M236684</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-07-02T14:02:55Z</dc:date>
    </item>
  </channel>
</rss>

