<?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: a question on %str() in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/a-question-on-str/m-p/949366#M371390</link>
    <description>#STR is used for masking characters which would otherwise be discarded (the blank) or have special meaning in macro language.&lt;BR /&gt;Since the opening parenthesis is also needed as a delimiter for %SCAN, it is also put in as an argument for %STR. But the function would treat the two consecutive opening/closing brackets as a pair, which is not wanted; therefore the bracket is masked with % to prevent this. You can find this in &lt;A href="https://documentation.sas.com/doc/de/pgmsascdc/9.4_3.5/mcrolref/n09tblrxldh8k0n1kt6dkj3xlxug.htm" target="_blank"&gt;https://documentation.sas.com/doc/de/pgmsascdc/9.4_3.5/mcrolref/n09tblrxldh8k0n1kt6dkj3xlxug.htm&lt;/A&gt; (the documentation of %STR).</description>
    <pubDate>Tue, 29 Oct 2024 15:40:17 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2024-10-29T15:40:17Z</dc:date>
    <item>
      <title>a question on %str()</title>
      <link>https://communities.sas.com/t5/SAS-Programming/a-question-on-str/m-p/949362#M371387</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have silly question: what does following code try to get?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%scan (&amp;amp;_indata,1,%str( %())&lt;/PRE&gt;
&lt;P&gt;it looks like it try to get the 1st segment&amp;nbsp; of &amp;amp;_indata.. I feel confused on the part&amp;nbsp;of "%str( %()". Could anyone interpretate that for me, especially the part with % and (.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2024 15:20:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/a-question-on-str/m-p/949362#M371387</guid>
      <dc:creator>stataq</dc:creator>
      <dc:date>2024-10-29T15:20:23Z</dc:date>
    </item>
    <item>
      <title>Re: a question on %str()</title>
      <link>https://communities.sas.com/t5/SAS-Programming/a-question-on-str/m-p/949364#M371388</link>
      <description>&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Maxims-of-Maximally-Efficient-SAS-Programmers/ta-p/352068/show-comments/false" target="_self"&gt;Maxim#1&lt;/A&gt;: Read the documentation&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/p0pnc7p9n4h6g5n16g6js048nhfl.htm" target="_blank"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/p0pnc7p9n4h6g5n16g6js048nhfl.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="yabwon_0-1730215911742.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/101853iE77D2C7E6125A9D7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="yabwon_0-1730215911742.png" alt="yabwon_0-1730215911742.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2024 15:32:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/a-question-on-str/m-p/949364#M371388</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2024-10-29T15:32:21Z</dc:date>
    </item>
    <item>
      <title>Re: a question on %str()</title>
      <link>https://communities.sas.com/t5/SAS-Programming/a-question-on-str/m-p/949365#M371389</link>
      <description>&lt;P&gt;The third position of the scan and %scan is the list of characters used as delimiters. So someone wanted to set the list characters to include the % sign as well as space and the parentheses as delimiters. Because the macro language uses % as a special character they needed to use the %str() to prevent using that % in the list as a macro trigger.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By default %scan would use any of the following as delimiters:blank ! $ % &amp;amp; ( ) * + , - . / ; &amp;lt; ^¦&lt;/P&gt;
&lt;P&gt;So one suspects that one or more of those characters were expected to appear in the values and they did not want those others to be treated as delimiters.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2024 15:40:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/a-question-on-str/m-p/949365#M371389</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-10-29T15:40:12Z</dc:date>
    </item>
    <item>
      <title>Re: a question on %str()</title>
      <link>https://communities.sas.com/t5/SAS-Programming/a-question-on-str/m-p/949366#M371390</link>
      <description>#STR is used for masking characters which would otherwise be discarded (the blank) or have special meaning in macro language.&lt;BR /&gt;Since the opening parenthesis is also needed as a delimiter for %SCAN, it is also put in as an argument for %STR. But the function would treat the two consecutive opening/closing brackets as a pair, which is not wanted; therefore the bracket is masked with % to prevent this. You can find this in &lt;A href="https://documentation.sas.com/doc/de/pgmsascdc/9.4_3.5/mcrolref/n09tblrxldh8k0n1kt6dkj3xlxug.htm" target="_blank"&gt;https://documentation.sas.com/doc/de/pgmsascdc/9.4_3.5/mcrolref/n09tblrxldh8k0n1kt6dkj3xlxug.htm&lt;/A&gt; (the documentation of %STR).</description>
      <pubDate>Tue, 29 Oct 2024 15:40:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/a-question-on-str/m-p/949366#M371390</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2024-10-29T15:40:17Z</dc:date>
    </item>
    <item>
      <title>Re: a question on %str()</title>
      <link>https://communities.sas.com/t5/SAS-Programming/a-question-on-str/m-p/949367#M371391</link>
      <description>&lt;P&gt;It extracts the dataset name from a macro variable that might hold a dataset name with dataset options.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let inds=sashelp.class(drop=age);
%let ds_only = %scan(&amp;amp;inds,1,%str( %());&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Results&lt;/P&gt;
&lt;PRE&gt;1    %let inds=sashelp.class(drop=age);
2    %let ds_only = %scan(&amp;amp;inds,1,%str( %());
3    %let libname = %upcase(%scan(work.&amp;amp;ds_only,-2,.));
4    %let memname = %upcase(%scan(&amp;amp;ds_only,-1,.));
5    %put &amp;amp;=inds &amp;amp;=ds_only &amp;amp;=libname &amp;amp;=memname;
INDS=sashelp.class(drop=age) DS_ONLY=sashelp.class LIBNAME=SASHELP MEMNAME=CLASS
6
7    %let inds=class;
8    %let ds_only = %scan(&amp;amp;inds,1,%str( %());
9    %let libname = %upcase(%scan(work.&amp;amp;ds_only,-2,.));
10   %let memname = %upcase(%scan(&amp;amp;ds_only,-1,.));
11   %put &amp;amp;=inds &amp;amp;=ds_only &amp;amp;=libname &amp;amp;=memname;
INDS=class DS_ONLY=class LIBNAME=WORK MEMNAME=CLASS
&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Oct 2024 15:49:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/a-question-on-str/m-p/949367#M371391</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-10-29T15:49:57Z</dc:date>
    </item>
  </channel>
</rss>

