<?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: %str inside of %sysfunc(ifc()) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/str-inside-of-sysfunc-ifc/m-p/905663#M357694</link>
    <description>&lt;P&gt;Thanks Tom. Combining with the reply from ballardw, I finally got what is going on: The unmasked comma in &amp;amp;final_class is regarded as one parameter separator by IFC in the macro facility, then only the first segment is returned since the condition evaluation is positive.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 01 Dec 2023 18:29:11 GMT</pubDate>
    <dc:creator>jason4sas</dc:creator>
    <dc:date>2023-12-01T18:29:11Z</dc:date>
    <item>
      <title>%str inside of %sysfunc(ifc())</title>
      <link>https://communities.sas.com/t5/SAS-Programming/str-inside-of-sysfunc-ifc/m-p/905184#M357533</link>
      <description>&lt;P&gt;I got a truncation issue when trying to conditionally add a comma before the string “a,b”:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let final_class= abv,bdev;&lt;/P&gt;&lt;P&gt;%put WARNING: %sysfunc(ifc(%length(&amp;amp;final_class.),%str(,&amp;amp;final_class.),));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;WARNING: ,abv&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I acknowledge that it can be fixed by an extra masking &amp;amp;final_class with %quote or something, but don't understand why it got truncated in the current setting. Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 29 Nov 2023 15:39:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/str-inside-of-sysfunc-ifc/m-p/905184#M357533</guid>
      <dc:creator>jason4sas</dc:creator>
      <dc:date>2023-11-29T15:39:41Z</dc:date>
    </item>
    <item>
      <title>Re: %str inside of %sysfunc(ifc())</title>
      <link>https://communities.sas.com/t5/SAS-Programming/str-inside-of-sysfunc-ifc/m-p/905200#M357537</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let final_class= abv,bdev;

%put WARNING: %sysfunc(ifc(%length(%superq(final_class)),%str(,)%superq(final_class),));
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 29 Nov 2023 16:27:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/str-inside-of-sysfunc-ifc/m-p/905200#M357537</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2023-11-29T16:27:14Z</dc:date>
    </item>
    <item>
      <title>Re: %str inside of %sysfunc(ifc())</title>
      <link>https://communities.sas.com/t5/SAS-Programming/str-inside-of-sysfunc-ifc/m-p/905209#M357541</link>
      <description>&lt;P&gt;Because %STR() is not quoting the value of the macro variable referenced.&lt;/P&gt;
&lt;P&gt;Use %QUOTE() instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In general %STR() is for quoting the text that is in your program.&amp;nbsp; If you want to quote text that is GENERATED by your program use something else.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Nov 2023 16:45:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/str-inside-of-sysfunc-ifc/m-p/905209#M357541</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-11-29T16:45:12Z</dc:date>
    </item>
    <item>
      <title>Re: %str inside of %sysfunc(ifc())</title>
      <link>https://communities.sas.com/t5/SAS-Programming/str-inside-of-sysfunc-ifc/m-p/905233#M357555</link>
      <description>&lt;P&gt;Agree. But still, how come the returned value is truncated? If I simply replace the macro variable with its true value, the truncation is not happening:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%put WARNING: %sysfunc(ifc(%length(abv,bdev),%str(,abv,bdev),));&lt;/P&gt;&lt;P&gt;WARNING: ,abv,bdev&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Therefore, it seems %str(,&amp;amp;final_class) coming with something unexpected inside of the %sysfunc.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Nov 2023 19:39:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/str-inside-of-sysfunc-ifc/m-p/905233#M357555</guid>
      <dc:creator>jason4sas</dc:creator>
      <dc:date>2023-11-29T19:39:08Z</dc:date>
    </item>
    <item>
      <title>Re: %str inside of %sysfunc(ifc())</title>
      <link>https://communities.sas.com/t5/SAS-Programming/str-inside-of-sysfunc-ifc/m-p/905252#M357556</link>
      <description>&lt;P&gt;Experiment. Use a different character than a comma in the middle. Does the same thing happen. If not, you might realize that the VALUE containing a comma is treated as providing the IFC function abc,def and so abc is treated like one of a list of comma separated values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Which why the suggestion to &lt;STRONG&gt;quote&lt;/STRONG&gt; the value. The basic call to a function with ifc(value, "abc.def") is different than ifc(value,abc,def)&lt;/P&gt;</description>
      <pubDate>Wed, 29 Nov 2023 20:21:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/str-inside-of-sysfunc-ifc/m-p/905252#M357556</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-11-29T20:21:18Z</dc:date>
    </item>
    <item>
      <title>Re: %str inside of %sysfunc(ifc())</title>
      <link>https://communities.sas.com/t5/SAS-Programming/str-inside-of-sysfunc-ifc/m-p/905271#M357569</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/251325"&gt;@jason4sas&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Agree. But still, how come the returned value is truncated? If I simply replace the macro variable with its true value, the truncation is not happening:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%put WARNING: %sysfunc(ifc(%length(abv,bdev),%str(,abv,bdev),));&lt;/P&gt;
&lt;P&gt;WARNING: ,abv,bdev&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Therefore, it seems %str(,&amp;amp;final_class) coming with something unexpected inside of the %sysfunc.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Because now there is something for %STR()&amp;nbsp; to quote.&amp;nbsp; &amp;nbsp;Before %STR() was ignoring the value of the macro variable.&amp;nbsp; That is not its job to worry about.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you look at the values that are stored in the SASHELP.VMACRO you can see how there is difference between the result of use %str() on A,B when it is text or when it is the result of expanding a macro variable reference.&lt;/P&gt;
&lt;PRE&gt;10   %let x=A,B;
11   %let y=%str(A,B);
12   %let z=%str(&amp;amp;x);
13
14   data _null_;
15     set sashelp.vmacro;
16     where name in ('X','Y','Z');
17     put name= value= +1 value $hex12.;
18   run;

name=X value=A,B  412C42202020
name=Y value=&amp;#1;A&amp;#30;B&amp;#2;  01411E420220
name=Z value=&amp;#1;A,B&amp;#2;  01412C420220
&lt;/PRE&gt;
&lt;P&gt;And if you use %QUOTE(&amp;amp;x) instead you get:&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;name=Z value=&amp;#3;A&amp;#30;B&amp;#8;  03411E420820
&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 29 Nov 2023 22:30:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/str-inside-of-sysfunc-ifc/m-p/905271#M357569</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-11-29T22:30:10Z</dc:date>
    </item>
    <item>
      <title>Re: %str inside of %sysfunc(ifc())</title>
      <link>https://communities.sas.com/t5/SAS-Programming/str-inside-of-sysfunc-ifc/m-p/905313#M357581</link>
      <description>&lt;P&gt;When it gets to a need of too much function nesting and quoting with macros level only then I find it often advantageous to use a data step instead.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let final_class= abv,bdev;
/*%put WARNING: %sysfunc(ifc(%length(&amp;amp;final_class.),%str(,&amp;amp;final_class.),));*/

data _null_;
  final_class="&amp;amp;final_class";
  if not missing(final_class) then call symputx('final_class',cats(',',final_class));
run;

%put final_class: %nrbquote(&amp;amp;final_class);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Nov 2023 07:27:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/str-inside-of-sysfunc-ifc/m-p/905313#M357581</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2023-11-30T07:27:12Z</dc:date>
    </item>
    <item>
      <title>Re: %str inside of %sysfunc(ifc())</title>
      <link>https://communities.sas.com/t5/SAS-Programming/str-inside-of-sysfunc-ifc/m-p/905663#M357694</link>
      <description>&lt;P&gt;Thanks Tom. Combining with the reply from ballardw, I finally got what is going on: The unmasked comma in &amp;amp;final_class is regarded as one parameter separator by IFC in the macro facility, then only the first segment is returned since the condition evaluation is positive.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Dec 2023 18:29:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/str-inside-of-sysfunc-ifc/m-p/905663#M357694</guid>
      <dc:creator>jason4sas</dc:creator>
      <dc:date>2023-12-01T18:29:11Z</dc:date>
    </item>
  </channel>
</rss>

