<?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: I need help understanding the %STR function in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/I-need-help-understanding-the-STR-function/m-p/889282#M351337</link>
    <description>&lt;P&gt;Without the %STR, &amp;amp; is interpreted as a macro trigger, but not as an argument to the PROPCASE function. Since PROPCASE then is not told that &amp;amp; is a word delimiter, the s in shoes stays lowercase.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Correction: since you omit the STR altogether, there ain't even a second argument to &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/n169kj2of5nur0n1bl1hubv55q63.htm" target="_blank" rel="noopener"&gt;PROPCASE&lt;/A&gt;, so only the default delimiters (which do not include the ampersand) are used.&lt;/P&gt;</description>
    <pubDate>Tue, 15 Aug 2023 06:05:10 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2023-08-15T06:05:10Z</dc:date>
    <item>
      <title>I need help understanding the %STR function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/I-need-help-understanding-the-STR-function/m-p/889277#M351333</link>
      <description>&lt;PRE&gt;&lt;CODE class=""&gt;%macro prodlist(prodline);
%let prodline=%qupcase(&amp;amp;prodline);

title "Listing of %qsysfunc(propcase(&amp;amp;prodline, %str( &amp;amp;)))";
proc print data=mc1.products;
    where upcase(Product_Line)="&amp;amp;prodline";
    var Product_ID Product_name Product_Line;
run;
title;
%mend prodlist;

%prodlist (%nrstr(clothes&amp;amp;shoes))&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;In the provided code, when the %str( &amp;amp;) is present in the title statement, the title displayed in the report becomes "Listing of Clothes&amp;amp;Shoes."&lt;BR /&gt;On the other hand, if the %str( &amp;amp;) is omitted and the title statement is written as "title "Listing of %qsysfunc(propcase(&amp;amp;prodline))";", the title in the report appears as "Listing of Clothes&amp;amp;shoes."&lt;BR /&gt;I'm curious why, when %str( &amp;amp;) is omitted, the propcase function doesn't seem to apply to the word "Shoes" in the title. Could you please explain why this happens?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Aug 2023 04:17:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/I-need-help-understanding-the-STR-function/m-p/889277#M351333</guid>
      <dc:creator>HY_KIM</dc:creator>
      <dc:date>2023-08-15T04:17:49Z</dc:date>
    </item>
    <item>
      <title>Re: I need help understanding the %STR function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/I-need-help-understanding-the-STR-function/m-p/889282#M351337</link>
      <description>&lt;P&gt;Without the %STR, &amp;amp; is interpreted as a macro trigger, but not as an argument to the PROPCASE function. Since PROPCASE then is not told that &amp;amp; is a word delimiter, the s in shoes stays lowercase.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Correction: since you omit the STR altogether, there ain't even a second argument to &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/n169kj2of5nur0n1bl1hubv55q63.htm" target="_blank" rel="noopener"&gt;PROPCASE&lt;/A&gt;, so only the default delimiters (which do not include the ampersand) are used.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Aug 2023 06:05:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/I-need-help-understanding-the-STR-function/m-p/889282#M351337</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-08-15T06:05:10Z</dc:date>
    </item>
    <item>
      <title>Re: I need help understanding the %STR function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/I-need-help-understanding-the-STR-function/m-p/889283#M351338</link>
      <description>&lt;P&gt;Suggestion: First, read the documentation for the PROPCASE function, do you know what the second parameter, when used, with propcase does?&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;DIV class="xis-refDictEntry"&gt;
&lt;DIV class="xis-syntax"&gt;
&lt;H2 id="p1489tvh6xtaxvn1u86emchjt489" class="xis-title"&gt;Syntax&lt;/H2&gt;
&lt;DIV class="xis-syntaxSimple"&gt;
&lt;DIV class="xis-syntaxLevel"&gt;&lt;SPAN class="xis-keyword"&gt;&lt;FONT style="background-color: #fcdec0;"&gt;PROPCASE&lt;/FONT&gt;&lt;/SPAN&gt;(&lt;SPAN class="xis-userSuppliedSyntaxValue"&gt;&lt;A title="Description of syntax: argument" href="http://127.0.0.1:57117/help/lefunctionsref.hlp/n169kj2of5nur0n1bl1hubv55q63.htm#n1dxojt45be5atn15ufmp9e7ngdb" target="_blank"&gt;argument&lt;/A&gt;&lt;/SPAN&gt; &lt;SPAN class="xis-argOptional"&gt;&amp;lt;, &lt;SPAN class="xis-userSuppliedSyntaxValue"&gt;&lt;A title="Description of syntax: delimiter" href="http://127.0.0.1:57117/help/lefunctionsref.hlp/n169kj2of5nur0n1bl1hubv55q63.htm#p1bx3hs6ogg43ln1if0w0tq2ucbe" target="_blank"&gt;delimiters&lt;/A&gt;&lt;/SPAN&gt;&amp;gt;&lt;/SPAN&gt;)&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV class="xis-syntaxDescription"&gt;
&lt;DIV class="xis-requiredArgGroup"&gt;
&lt;H3 id="n0yhkszfeqt1u5n1dty0tpyf9cf0" class="xis-title"&gt;Required Argument&lt;/H3&gt;
&lt;DIV id="n1dxojt45be5atn15ufmp9e7ngdb" class="xis-argDescriptionPair"&gt;
&lt;H4 class="xis-argument"&gt;&lt;SPAN class="xis-userSuppliedValue"&gt;argument&lt;/SPAN&gt;&lt;/H4&gt;
&lt;DIV class="xis-argumentDescription"&gt;
&lt;P class="xis-paraSimpleFirst"&gt;specifies a character constant, variable, or expression.&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV class="xis-optionalArgGroup"&gt;
&lt;H3 id="n1sdr35dcho9rdn1248zuf9bv0fc" class="xis-title"&gt;Optional Argument&lt;/H3&gt;
&lt;DIV id="p1bx3hs6ogg43ln1if0w0tq2ucbe" class="xis-argDescriptionPair"&gt;
&lt;H4 class="xis-argument"&gt;&lt;SPAN class="xis-userSuppliedValue"&gt;delimiter&lt;/SPAN&gt;&lt;/H4&gt;
&lt;DIV class="xis-argumentDescription"&gt;
&lt;P class="xis-paraSimpleFirst"&gt;specifies one or more delimiters that are enclosed in quotation marks. The default delimiters are blank, forward slash, hyphen, open parenthesis, period, and tab.&lt;/P&gt;
&lt;TABLE class="xis-summary"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="xis-summaryTip"&gt;Tip&lt;/TD&gt;
&lt;TD class="xis-summaryText"&gt;If you use this argument, then the default delimiters, including the blank, are no longer in effect.&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So the second parameter tells the Propcase function what to use to separate "words" before applying letter case change.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But the &amp;amp; is critical character and will get treated by the MACRO processor as the indicator of the start of a macro variable name.&amp;nbsp; So the %str function masks the &amp;amp; from being treated as such and allows use as a delimiter instead of macro token. The standard list of delimiters used by the Propcase function are blank, forward slash, hyphen, open parenthesis, period, and tab. So the &amp;amp; is not a delimiter unless forced and the second "word" that people see is not treated as a separate word,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now use this: Clothes socks&amp;amp;shoes as the value passed to macro. What should Propcase do to that? Or just test in&amp;nbsp; a data step.&lt;/P&gt;
&lt;PRE&gt;data junk;
   x=propcase('Clothes socks&amp;amp;shoes');
   y=propcase('Clothes socks&amp;amp;shoes','&amp;amp;');
   z=propcase('Clothes socks&amp;amp;shoes',' &amp;amp;');
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Aug 2023 06:09:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/I-need-help-understanding-the-STR-function/m-p/889283#M351338</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-08-15T06:09:27Z</dc:date>
    </item>
    <item>
      <title>Re: I need help understanding the %STR function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/I-need-help-understanding-the-STR-function/m-p/889339#M351362</link>
      <description>&lt;P&gt;You don't need the %STR() for the &amp;amp; in the delimiter argument since it is not followed by a letter or digit it will not be confused for a macro trigger.&lt;/P&gt;
&lt;P&gt;But you do need it for the space character.&lt;/P&gt;
&lt;P&gt;Try it with&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%str( )&amp;amp;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Instead of&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%str( &amp;amp;)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and you should see the same results.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Aug 2023 13:11:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/I-need-help-understanding-the-STR-function/m-p/889339#M351362</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-08-15T13:11:49Z</dc:date>
    </item>
  </channel>
</rss>

