<?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: Need help with macro variable not resolving correctly inside of a macro. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-macro-variable-not-resolving-correctly-inside-of/m-p/257957#M49587</link>
    <description>&lt;P&gt;How the user enter the values? do you have a SAS Stored Process?&lt;/P&gt;</description>
    <pubDate>Mon, 21 Mar 2016 14:05:06 GMT</pubDate>
    <dc:creator>Loko</dc:creator>
    <dc:date>2016-03-21T14:05:06Z</dc:date>
    <item>
      <title>Need help with macro variable not resolving correctly inside of a macro.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-macro-variable-not-resolving-correctly-inside-of/m-p/257956#M49586</link>
      <description>&lt;P&gt;I am trying to assign the variable of 'NEW_STATE' to the prompt value the user has entered and wrap the value in quotes to use in building my where clause.&amp;nbsp;&amp;nbsp; When I try to run it, I get no results because the assignment of the variable 'NEW_STATE' is not correct.&amp;nbsp; Here is my code:&lt;/P&gt;
&lt;PRE&gt;%macro BuildWhereClause;
   %global where_clause;
   %let where_clause = ;

/* check prompt STATE for user entered values */
  %if %length(&amp;amp;STATE) &amp;gt; 0 %then %do ;       &lt;BR /&gt;      %let NEW_STATE = '&amp;amp;STATE';
      %let where_clause = &amp;amp;where_clause AND UPCASE(t1.STATE) = UPCASE(&amp;amp;NEW_STATE);
  %end;
 
/* display values of demograpic prompts */
%put &amp;amp;STATE;
%put &amp;amp;NEW_STATE;

%put ******** where_clause is = &amp;amp;where_clause; 


%mend;
%BuildWhereClause; 


Value of the variables from the %put statements:

NC        --  value of &amp;amp;STATE, user entered prompt.
'&amp;amp;STATE'  --  value of &amp;amp;NEW_STATE    I need this to have the value of  UPCASE('NC')  

******** where_clause is = AND UPCASE(t1.STATE) = UPCASE('&amp;amp;STATE') This needs to be UPCASE('NC')  

&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Mar 2016 13:55:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-macro-variable-not-resolving-correctly-inside-of/m-p/257956#M49586</guid>
      <dc:creator>ncsthbell</dc:creator>
      <dc:date>2016-03-21T13:55:59Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with macro variable not resolving correctly inside of a macro.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-macro-variable-not-resolving-correctly-inside-of/m-p/257957#M49587</link>
      <description>&lt;P&gt;How the user enter the values? do you have a SAS Stored Process?&lt;/P&gt;</description>
      <pubDate>Mon, 21 Mar 2016 14:05:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-macro-variable-not-resolving-correctly-inside-of/m-p/257957#M49587</guid>
      <dc:creator>Loko</dc:creator>
      <dc:date>2016-03-21T14:05:06Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with macro variable not resolving correctly inside of a macro.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-macro-variable-not-resolving-correctly-inside-of/m-p/257959#M49589</link>
      <description>&lt;P&gt;Single quotes suppress all macro activity.&amp;nbsp; Switch to double quotes:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let NEW_STATE = "&amp;amp;STATE";&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also note, this works as long as &amp;amp;STATE contains just a single state code.&amp;nbsp; If it could contain multiple state codes, you will need to quote each one individually.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Mar 2016 14:10:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-macro-variable-not-resolving-correctly-inside-of/m-p/257959#M49589</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-03-21T14:10:18Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with macro variable not resolving correctly inside of a macro.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-macro-variable-not-resolving-correctly-inside-of/m-p/257964#M49592</link>
      <description>&lt;P&gt;Worked perfectly!!&amp;nbsp;&amp;nbsp; I did not realize that the single quotes would suppress the macro activity.&amp;nbsp; Learn something new everyday with SAS!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks a bunch!&lt;/P&gt;</description>
      <pubDate>Mon, 21 Mar 2016 14:24:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-macro-variable-not-resolving-correctly-inside-of/m-p/257964#M49592</guid>
      <dc:creator>ncsthbell</dc:creator>
      <dc:date>2016-03-21T14:24:54Z</dc:date>
    </item>
  </channel>
</rss>

