<?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: How to resolve Concatenation(||) and percent,&amp;amp; symbols in macros in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-resolve-Concatenation-and-percent-amp-symbols-in-macros/m-p/710524#M218733</link>
    <description>&lt;P&gt;To concatenate macro variables you cant use '||' (nor '!!').&lt;/P&gt;
&lt;P&gt;In order to dislay the &amp;amp;cntry value you must use double quotes.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Check next code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro EM(cntry=);
	%let cntr = %sysfunc(compress(&amp;amp;cntry.));
	%put cntry resolves to &amp;amp;cntry ;
	%if "&amp;amp;cntry."="OMAN" or "&amp;amp;cntry." = "CHINA" 
	   %then %let like_cntry=%nrbquote("&amp;amp;cntry.%");  
	   %else %let like_cntry=%nrbquote(%)&amp;amp;cntry.%nrbquote(%);
    %put like_cntry resolves to &amp;amp;like_cntry.;
%mend;
%em(cntry=OMAN);
%em(cntry=japan);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 11 Jan 2021 11:20:57 GMT</pubDate>
    <dc:creator>Shmuel</dc:creator>
    <dc:date>2021-01-11T11:20:57Z</dc:date>
    <item>
      <title>How to resolve Concatenation(||) and percent,&amp; symbols in macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-resolve-Concatenation-and-percent-amp-symbols-in-macros/m-p/710518#M218729</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro EM(cntry=);

%let cntr = %sysfunc(compress(&amp;amp;cntry.));

%put cntry resolves to &amp;amp;cntry ;

%if "&amp;amp;cntry."="OMAN" or "&amp;amp;cntry." = "CHINA" %then %let like_cntry=%nrbquote('&amp;amp;cntry.%');  
 %else %let like_cntry=%nrquote('%')||%bquote('&amp;amp;cntry.')||%nrquote('%') ;

%put like_cntry resolves to &amp;amp;like_cntry.;
%mend
%em(cntry=japan)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to resolve &amp;amp;like_cntry as&amp;nbsp; '%japan%'&amp;nbsp; since iam using in where clause&lt;/P&gt;&lt;P&gt;when i was trying to resolve iam getting this output&amp;nbsp; '%'||'japan'||'%'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone help me on this?&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jan 2021 10:56:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-resolve-Concatenation-and-percent-amp-symbols-in-macros/m-p/710518#M218729</guid>
      <dc:creator>Siva_Harish</dc:creator>
      <dc:date>2021-01-11T10:56:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to resolve Concatenation(||) and percent,&amp; symbols in macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-resolve-Concatenation-and-percent-amp-symbols-in-macros/m-p/710524#M218733</link>
      <description>&lt;P&gt;To concatenate macro variables you cant use '||' (nor '!!').&lt;/P&gt;
&lt;P&gt;In order to dislay the &amp;amp;cntry value you must use double quotes.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Check next code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro EM(cntry=);
	%let cntr = %sysfunc(compress(&amp;amp;cntry.));
	%put cntry resolves to &amp;amp;cntry ;
	%if "&amp;amp;cntry."="OMAN" or "&amp;amp;cntry." = "CHINA" 
	   %then %let like_cntry=%nrbquote("&amp;amp;cntry.%");  
	   %else %let like_cntry=%nrbquote(%)&amp;amp;cntry.%nrbquote(%);
    %put like_cntry resolves to &amp;amp;like_cntry.;
%mend;
%em(cntry=OMAN);
%em(cntry=japan);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 11 Jan 2021 11:20:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-resolve-Concatenation-and-percent-amp-symbols-in-macros/m-p/710524#M218733</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2021-01-11T11:20:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to resolve Concatenation(||) and percent,&amp; symbols in macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-resolve-Concatenation-and-percent-amp-symbols-in-macros/m-p/710527#M218735</link>
      <description>&lt;P&gt;t can be even more simple - both methods were tested:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro EM(cntry=);
	%let cntr = %sysfunc(compress(&amp;amp;cntry.));
	%put cntry resolves to &amp;amp;cntry ;
	%if "&amp;amp;cntry."="OMAN" or "&amp;amp;cntry." = "CHINA" 
	   %then %let like_cntry=&amp;amp;cntry.%;  
	   %else %let like_cntry=%nrbquote(%)&amp;amp;cntry.%; /*nrbquote(%);*/
    %put like_cntry resolves to &amp;amp;like_cntry.;
%mend;
%em(cntry=OMAN);
%em(cntry=japan);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 11 Jan 2021 11:28:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-resolve-Concatenation-and-percent-amp-symbols-in-macros/m-p/710527#M218735</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2021-01-11T11:28:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to resolve Concatenation(||) and percent,&amp; symbols in macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-resolve-Concatenation-and-percent-amp-symbols-in-macros/m-p/710528#M218736</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What is the following instruction used for ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;%let cntr = %sysfunc(compress(&amp;amp;cntry.));&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to remove leading and trailing blanks, the following will be enough :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let cntr=&amp;amp;cntry.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;By using compress, you also remove blanks in the country name so "COSTA RICA", for instance, will become "COSTARICA".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try the following code and look at the log :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _NULL_;
call symput("cntry","  COSTA RICA   ");
run;

%put ***&amp;amp;=cntry.***;

%let cntr = %sysfunc(compress(&amp;amp;cntry.));

%put ***&amp;amp;=cntr.***;

%let cntr2=&amp;amp;cntry.;

%put ***&amp;amp;=cntr2.***;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that it would not have been necessary if symputx had been used instead of symput.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jan 2021 11:34:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-resolve-Concatenation-and-percent-amp-symbols-in-macros/m-p/710528#M218736</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2021-01-11T11:34:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to resolve Concatenation(||) and percent,&amp; symbols in macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-resolve-Concatenation-and-percent-amp-symbols-in-macros/m-p/710535#M218743</link>
      <description>&lt;PRE&gt;%macro EM(cntry=)/minoperator mindelimiter=',';
%put cntry resolves to &amp;amp;cntry ;

%if %upcase(&amp;amp;cntry.) in OMAN,CHINA %then %let like_cntry=%bquote('&amp;amp;cntry.%');  
 %else %let like_cntry=%sysfunc(compress(%bquote('% &amp;amp;cntry.%'),%str( ))) ;

%put like_cntry resolves to &amp;amp;like_cntry.;
%mend;
%em(cntry=japan)
%em(cntry=china)
&lt;/PRE&gt;
&lt;P&gt;How about this one ?&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jan 2021 12:33:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-resolve-Concatenation-and-percent-amp-symbols-in-macros/m-p/710535#M218743</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-01-11T12:33:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to resolve Concatenation(||) and percent,&amp; symbols in macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-resolve-Concatenation-and-percent-amp-symbols-in-macros/m-p/710559#M218753</link>
      <description>&lt;P&gt;To put the values of macro variables next to each other just evaluate them next to each.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&amp;amp;X.&amp;amp;Y.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you just remove the spurious vertical bar characters from your source code then and they won't end up in the generated code.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jan 2021 14:51:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-resolve-Concatenation-and-percent-amp-symbols-in-macros/m-p/710559#M218753</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-01-11T14:51:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to resolve Concatenation(||) and percent,&amp; symbols in macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-resolve-Concatenation-and-percent-amp-symbols-in-macros/m-p/713393#M220080</link>
      <description>This also worked for me but i want '%japan%' (including quotes) . I resolved the issue .Thank you..!!</description>
      <pubDate>Fri, 22 Jan 2021 15:59:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-resolve-Concatenation-and-percent-amp-symbols-in-macros/m-p/713393#M220080</guid>
      <dc:creator>Siva_Harish</dc:creator>
      <dc:date>2021-01-22T15:59:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to resolve Concatenation(||) and percent,&amp; symbols in macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-resolve-Concatenation-and-percent-amp-symbols-in-macros/m-p/713581#M220166</link>
      <description>Did you run my code ?&lt;BR /&gt;&lt;BR /&gt;1    %macro EM(cntry=)/minoperator mindelimiter=',';&lt;BR /&gt;2    %put cntry resolves to &amp;amp;cntry ;&lt;BR /&gt;3&lt;BR /&gt;4    %if %upcase(&amp;amp;cntry.) in OMAN,CHINA %then %let like_cntry=%bquote('&amp;amp;cntry.%');&lt;BR /&gt;5     %else %let like_cntry=%sysfunc(compress(%bquote('% &amp;amp;cntry.%'),%str( ))) ;&lt;BR /&gt;6&lt;BR /&gt;7    %put like_cntry resolves to &amp;amp;like_cntry.;&lt;BR /&gt;8    %mend;&lt;BR /&gt;9    %em(cntry=japan)&lt;BR /&gt;cntry resolves to japan&lt;BR /&gt;like_cntry resolves to '%japan%'&lt;BR /&gt;10   %em(cntry=china)&lt;BR /&gt;cntry resolves to china&lt;BR /&gt;like_cntry resolves to 'china%'&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sat, 23 Jan 2021 10:37:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-resolve-Concatenation-and-percent-amp-symbols-in-macros/m-p/713581#M220166</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-01-23T10:37:54Z</dc:date>
    </item>
  </channel>
</rss>

