<?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: when we should use %bquote() in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/when-we-should-use-bquote/m-p/937160#M368233</link>
    <description>&lt;P&gt;If your goal is to check whether this macro parameter is empty/blank, this is the commonly used pattern in the form of a macro function:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;/* Reliable way to check whether a macro value is empty/blank */
%macro isBlank(param);
  %sysevalf(%superq(param)=,boolean)
%mend;


...
if %isBlank(&amp;amp;_rowlbl) %then %do;
...&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 25 Jul 2024 17:47:27 GMT</pubDate>
    <dc:creator>ChrisHemedinger</dc:creator>
    <dc:date>2024-07-25T17:47:27Z</dc:date>
    <item>
      <title>when we should use %bquote()</title>
      <link>https://communities.sas.com/t5/SAS-Programming/when-we-should-use-bquote/m-p/937155#M368231</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to understand when&amp;nbsp; to use&amp;nbsp;%bquote() and how it works. I have following code setup as exercise. If I keep it as is, it won't work. If I changed 'not work' line to the next row it will work:&lt;/P&gt;
&lt;PRE&gt;data df;
infile datalines dsd truncover;
input rowlbl $ sex $ stop;
datalines;
Y,Female,0
;
%macro m_lbl( grp=, _rowlbl=%bquote() );
data df;
length rowlbl $200.;
set df;
		grp=&amp;amp;grp.;

		%if &amp;amp;_rowlbl ne %bquote()  %then %do;
		 rowlbl=%bquote(&amp;amp;_rowlbl.);  /*not work*/&lt;BR /&gt;        /*       rowlbl=&amp;amp;_rowlbl.;  */ /*not work*/
 	/*	 rowlbl="&amp;amp;_rowlbl.";   */ /*work*/
		%end;
run;
%mend;

%m_lbl( grp=1, _rowlbl=%bquote(Gender, n (%)) );&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Could anyone tell me why I can't use ' rowlbl=%bquote(&amp;amp;_rowlbl.); ' in my code? Maybe also some guideance on when we should use&amp;nbsp;&amp;nbsp;%bquote(&amp;amp;_rowlbl.), when we should use &amp;amp;_rowlbl. , and when we should use "&amp;amp;_rowlbl.".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jul 2024 17:19:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/when-we-should-use-bquote/m-p/937155#M368231</guid>
      <dc:creator>stataq</dc:creator>
      <dc:date>2024-07-25T17:19:08Z</dc:date>
    </item>
    <item>
      <title>Re: when we should use %bquote()</title>
      <link>https://communities.sas.com/t5/SAS-Programming/when-we-should-use-bquote/m-p/937158#M368232</link>
      <description>&lt;P&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/p06cx7fegzmzpen1m9991yljxiav.htm" target="_blank" rel="noopener"&gt;%BQUOTE&lt;/A&gt;&amp;nbsp;is for masking special characters and strings (like AND), so that they are not resolved by the macro processor. Use it only for this purpose.&lt;/P&gt;
&lt;P&gt;It does not put quotes around a string.&lt;/P&gt;
&lt;P&gt;If a macro variable contains character data, enclose it in quotes in SAS code; if it contains numeric data, do not use quotes.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jul 2024 17:39:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/when-we-should-use-bquote/m-p/937158#M368232</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2024-07-25T17:39:52Z</dc:date>
    </item>
    <item>
      <title>Re: when we should use %bquote()</title>
      <link>https://communities.sas.com/t5/SAS-Programming/when-we-should-use-bquote/m-p/937160#M368233</link>
      <description>&lt;P&gt;If your goal is to check whether this macro parameter is empty/blank, this is the commonly used pattern in the form of a macro function:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;/* Reliable way to check whether a macro value is empty/blank */
%macro isBlank(param);
  %sysevalf(%superq(param)=,boolean)
%mend;


...
if %isBlank(&amp;amp;_rowlbl) %then %do;
...&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jul 2024 17:47:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/when-we-should-use-bquote/m-p/937160#M368233</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2024-07-25T17:47:27Z</dc:date>
    </item>
    <item>
      <title>Re: when we should use %bquote()</title>
      <link>https://communities.sas.com/t5/SAS-Programming/when-we-should-use-bquote/m-p/937163#M368234</link>
      <description>&lt;P&gt;As&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;said you issue is not with your macro logic.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instead your issue is with the SAS code you are trying to use the macro logic to generate.&amp;nbsp; Both of these statements:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;rowlbl=%bquote(&amp;amp;_rowlbl.);  
rowlbl=&amp;amp;_rowlbl.;  &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Will generate this SAS code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;rowlbl=Gender, n (%);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Does that look like valid SAS code to you?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to add quotes use the QUOTE() function.&amp;nbsp; You can use the optional second argument to the QUOTE() function to have the string bounded by single quotes to prevent any embedded macro triggers from being seen by the macro processor.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;rowlbl=%sysfunc(quote(%bquote(&amp;amp;_rowlbl.),%str(%')));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Which will generate this SAS code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;rowlbl='Gender, n (%)';&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Jul 2024 18:07:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/when-we-should-use-bquote/m-p/937163#M368234</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-07-25T18:07:46Z</dc:date>
    </item>
    <item>
      <title>Re: when we should use %bquote()</title>
      <link>https://communities.sas.com/t5/SAS-Programming/when-we-should-use-bquote/m-p/937166#M368236</link>
      <description>Hi:&lt;BR /&gt;  I always find this chart about the quoting functions to be useful:&lt;BR /&gt;&lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/p0pwrvnlcooi3tn0z3g1755ebcng.htm" target="_blank"&gt;https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/p0pwrvnlcooi3tn0z3g1755ebcng.htm&lt;/A&gt;&lt;BR /&gt;(title: Summary of Macro Quoting Functions and the Characters That They Mask)&lt;BR /&gt;Cynthia</description>
      <pubDate>Thu, 25 Jul 2024 18:31:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/when-we-should-use-bquote/m-p/937166#M368236</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2024-07-25T18:31:15Z</dc:date>
    </item>
  </channel>
</rss>

