<?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 Difference between upcase and %upcase? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Difference-between-upcase-and-upcase/m-p/116106#M23942</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all, I was trying to use macro to convert the case of a character variable, but I was confused with the usage of upcase and %upcase. Below is the sample code that I used. The chgCase macro is supposed to convert the input string to upper case and return the converted string to the data step. The following code is always working. However, if I replaced upcase(&amp;amp;input) with %upcase(&amp;amp;input), then the case of the input string won't be converted, newName stored the same string as the original text. And SAS enterprise guide didn't report any error or warning. I am wondering why %upcase won't work within my macro? Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data name;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; input name $;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;Jones&lt;/P&gt;&lt;P&gt;White&lt;/P&gt;&lt;P&gt;Smith&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%macro chgCase(input);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let newText=&lt;STRONG style="color: #ff0000;"&gt;upcase(&amp;amp;input)&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp;newText&lt;/P&gt;&lt;P&gt;%mend chgCase;&lt;/P&gt;&lt;P&gt;data name;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set name;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; newName=%chgCase(name);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 09 Sep 2012 02:05:22 GMT</pubDate>
    <dc:creator>zhouzy99</dc:creator>
    <dc:date>2012-09-09T02:05:22Z</dc:date>
    <item>
      <title>Difference between upcase and %upcase?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Difference-between-upcase-and-upcase/m-p/116106#M23942</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all, I was trying to use macro to convert the case of a character variable, but I was confused with the usage of upcase and %upcase. Below is the sample code that I used. The chgCase macro is supposed to convert the input string to upper case and return the converted string to the data step. The following code is always working. However, if I replaced upcase(&amp;amp;input) with %upcase(&amp;amp;input), then the case of the input string won't be converted, newName stored the same string as the original text. And SAS enterprise guide didn't report any error or warning. I am wondering why %upcase won't work within my macro? Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data name;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; input name $;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;Jones&lt;/P&gt;&lt;P&gt;White&lt;/P&gt;&lt;P&gt;Smith&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%macro chgCase(input);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let newText=&lt;STRONG style="color: #ff0000;"&gt;upcase(&amp;amp;input)&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp;newText&lt;/P&gt;&lt;P&gt;%mend chgCase;&lt;/P&gt;&lt;P&gt;data name;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set name;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; newName=%chgCase(name);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 09 Sep 2012 02:05:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Difference-between-upcase-and-upcase/m-p/116106#M23942</guid>
      <dc:creator>zhouzy99</dc:creator>
      <dc:date>2012-09-09T02:05:22Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between upcase and %upcase?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Difference-between-upcase-and-upcase/m-p/116107#M23943</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Macro just generates text. So in your example the text it is generating is:&amp;nbsp; upcase(name).&amp;nbsp; &lt;/P&gt;&lt;P&gt;If instead you change the macro to use %upcase then the text it will generate is: NAME.&lt;/P&gt;&lt;P&gt;So the name of the variable is now in uppercase, but that will have no effect on the values of the variable that get assigned to the new dataset variable.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 09 Sep 2012 02:41:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Difference-between-upcase-and-upcase/m-p/116107#M23943</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-09-09T02:41:03Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between upcase and %upcase?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Difference-between-upcase-and-upcase/m-p/116108#M23944</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Besides Tom's dead-on point, %upcase() will only work on macro variables, while upcase() will only work on data set variables without stacking other macro functions, so in your case, you HAVE to use upcase().&lt;/P&gt;&lt;P&gt;Also, invoking options like symbolgen, mprint, mlogic will help you troubleshoot macros.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 09 Sep 2012 02:48:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Difference-between-upcase-and-upcase/m-p/116108#M23944</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-09-09T02:48:29Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between upcase and %upcase?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Difference-between-upcase-and-upcase/m-p/116109#M23945</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 09 Sep 2012 02:52:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Difference-between-upcase-and-upcase/m-p/116109#M23945</guid>
      <dc:creator>zhouzy99</dc:creator>
      <dc:date>2012-09-09T02:52:29Z</dc:date>
    </item>
  </channel>
</rss>

