<?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 Macro variable value with single quote in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-value-with-single-quote/m-p/765544#M242493</link>
    <description>&lt;P&gt;I've the code as follows. I"m getting the error if I execute it. Any help to&amp;nbsp;resolve the error?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you look at the value &lt;STRONG&gt;closing run' insurance, &lt;/STRONG&gt;I've single quote after the string run which I want in the result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%let rep_run=%upcase('closing run' insurance','insurance','secondary closing run insurance','business insurance','RI_BCT');
%put &amp;amp;=rep_run;
&lt;/PRE&gt;
&lt;P&gt;Error message:&lt;/P&gt;
&lt;PRE&gt;26         %let rep_run=%upcase('closing run' insurance','insurance','secondary closing run insurance','business
                                                       ___         ___                                                    ___
                                                       49          49                                                     49
26       ! insurance','RI_BCT');
ERROR: Open code statement recursion detected.&lt;/PRE&gt;
&lt;P&gt;Desired Result:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;'CLOSING RUN' INSURANCE','INSURANCE','SECONDARY CLOSING RUN INSURANCE','BUSINESS INSURANCE','RI_BCT'&lt;/PRE&gt;</description>
    <pubDate>Thu, 02 Sep 2021 06:06:14 GMT</pubDate>
    <dc:creator>David_Billa</dc:creator>
    <dc:date>2021-09-02T06:06:14Z</dc:date>
    <item>
      <title>Macro variable value with single quote</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-value-with-single-quote/m-p/765544#M242493</link>
      <description>&lt;P&gt;I've the code as follows. I"m getting the error if I execute it. Any help to&amp;nbsp;resolve the error?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you look at the value &lt;STRONG&gt;closing run' insurance, &lt;/STRONG&gt;I've single quote after the string run which I want in the result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%let rep_run=%upcase('closing run' insurance','insurance','secondary closing run insurance','business insurance','RI_BCT');
%put &amp;amp;=rep_run;
&lt;/PRE&gt;
&lt;P&gt;Error message:&lt;/P&gt;
&lt;PRE&gt;26         %let rep_run=%upcase('closing run' insurance','insurance','secondary closing run insurance','business
                                                       ___         ___                                                    ___
                                                       49          49                                                     49
26       ! insurance','RI_BCT');
ERROR: Open code statement recursion detected.&lt;/PRE&gt;
&lt;P&gt;Desired Result:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;'CLOSING RUN' INSURANCE','INSURANCE','SECONDARY CLOSING RUN INSURANCE','BUSINESS INSURANCE','RI_BCT'&lt;/PRE&gt;</description>
      <pubDate>Thu, 02 Sep 2021 06:06:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-value-with-single-quote/m-p/765544#M242493</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2021-09-02T06:06:14Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable value with single quote</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-value-with-single-quote/m-p/765551#M242494</link>
      <description>&lt;P&gt;First of all, %upcase cannot be used in open code.&lt;/P&gt;
&lt;P&gt;It is used in %Macro-%Mend block.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Therefore, I think the easiest way is to enclose the string you want to process in double quotation marks and assign it to a macro variable using call symput in data step.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  call symput('rep_run',upcase("'closing run' insurance','insurance','secondary closing run insurance','business insurance','RI_BCT'"));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 02 Sep 2021 06:37:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-value-with-single-quote/m-p/765551#M242494</guid>
      <dc:creator>japelin</dc:creator>
      <dc:date>2021-09-02T06:37:31Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable value with single quote</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-value-with-single-quote/m-p/765553#M242495</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/226565"&gt;@japelin&lt;/a&gt;&amp;nbsp;I just ran your code. Is this not an error?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Log:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;26       !  data _null_;
27           call symput('rep_run',upcase("'closing run' insurance','insurance','secondary closing run insurance','business
27       ! insurance','RI_BCT'"));
28         run;

NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

29         
30         %put ####&amp;amp;rep_run.;
NOTE: Line generated by the macro variable "REP_RUN".
30         'CLOSING RUN' INSURANCE','INSURANCE','SECONDARY CLOSING RUN INSURANCE','BUSINESS INSURANCE','RI_BCT'
                                  ___         ___                                                    ___
                                  49          49                                                     49&lt;/PRE&gt;</description>
      <pubDate>Thu, 02 Sep 2021 07:01:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-value-with-single-quote/m-p/765553#M242495</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2021-09-02T07:01:34Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable value with single quote</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-value-with-single-quote/m-p/765555#M242496</link>
      <description>&lt;P&gt;You must always take care that the code&amp;nbsp;&lt;EM&gt;created through the resolution of macro triggers&lt;/EM&gt; is valid. As you can see, here it is not.&lt;/P&gt;
&lt;P&gt;If the resolution of a macro variable causes problems is determined by the context in which the variable is resolved. What do you intend to do with this macro variable?&lt;/P&gt;
&lt;P&gt;For instance, this works:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%put "&amp;amp;rep_run";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;because the unbalanced single quotes are alleviated by the whole string being enclosed in double quotes.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Sep 2021 07:10:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-value-with-single-quote/m-p/765555#M242496</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-09-02T07:10:58Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable value with single quote</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-value-with-single-quote/m-p/765567#M242499</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;I want to use the macro variable value to use in SQL Server tables to check for values. As SQL server will consider only single quote for the string, how to tackle it now?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to know how to handle case when here when you want to compare the macro variable values&amp;nbsp;with SQL server field values?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Proc Sql noprint;
	Connect to SQLSERVER (DATAsrc=&amp;amp;DATASRC. AUTHDOMAIN="XXXXX." dbMax_text=32767);
	Execute ( Insert into Meta_cntrl Select Distinct
		NULL as org_id
	Case 
		When (rep_run) in (&amp;amp;rep_run.) 
		then 'PI_PPT' 
	else  ' '
	end
    as reporting_value;
	) by SQLSERVER;
	;
	Disconnect from SQLSERVER;
quit;&lt;/PRE&gt;</description>
      <pubDate>Thu, 02 Sep 2021 08:05:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-value-with-single-quote/m-p/765567#M242499</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2021-09-02T08:05:19Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable value with single quote</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-value-with-single-quote/m-p/765579#M242508</link>
      <description>&lt;P&gt;Then try to submit this and then submit your proc sql code.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  call symput('rep_run',upcase("'closing run'' insurance','insurance','secondary closing run insurance','business insurance','RI_BCT'"));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 02 Sep 2021 09:00:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-value-with-single-quote/m-p/765579#M242508</guid>
      <dc:creator>japelin</dc:creator>
      <dc:date>2021-09-02T09:00:15Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable value with single quote</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-value-with-single-quote/m-p/765580#M242509</link>
      <description>&lt;P&gt;Two things here,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1) To handle single quote in a text string surrounded by single quotes you have to escape it by doubling it, e.g.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  x = "ab'cd"; /* no need for escape */
  y = 'ab''cd'; /* escape ' by doubling it */
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;By the way, for handling single quote, you can use my code from this thread:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/Macro-Variable-values-to-enclose-with-single-quote/m-p/765288" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/Macro-Variable-values-to-enclose-with-single-quote/m-p/765288&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  call symputx("rep_run", "closing run' insurance,insurance,secondary closing run insurance,business insurance,RI_BCT");
run;
%put rep_run=%superq(rep_run);

data _null_;
  length text str rep_run $ 32767;
  text = symget("rep_run");

    do _N_= 1 to countw(text, ",");
      str = scan(text, _N_, ",");
      rep_run = catx(",", rep_run, quote(upcase(strip(str)),"'"));
    end;

  call symputx("rep_run", rep_run, "G");
run;
%put rep_run=%superq(rep_run);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2) The Error you have in the code is because the single quote in the text "closing run' insurance". It is "breaking SAS quotes handling" and the&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;---
49&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;is because SAS see text:&lt;/P&gt;
&lt;PRE&gt;','i&lt;/PRE&gt;
&lt;P&gt;and interprets it as "&lt;EM&gt;possible in the future&lt;/EM&gt;" special text string like these:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;'02sep2021'd 
'12:34:56't 
'1001101101'b
'some crazy name'n&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;are.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;All the best&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Sep 2021 09:02:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-value-with-single-quote/m-p/765580#M242509</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2021-09-02T09:02:42Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable value with single quote</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-value-with-single-quote/m-p/765581#M242510</link>
      <description>Ok. Can I call the macro variable in proc SQL connect to SQL server without&lt;BR /&gt;any double quotes around?&lt;BR /&gt;</description>
      <pubDate>Thu, 02 Sep 2021 09:05:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-value-with-single-quote/m-p/765581#M242510</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2021-09-02T09:05:11Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable value with single quote</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-value-with-single-quote/m-p/765582#M242511</link>
      <description>You evidently sent to some effort to add single quotes around each item in your list.  Go back to that section of your code, add double quotes instead of single quotes.  Keep the embedded single quote within closing run' insurance as is.  The rest (including %upcase) should work.</description>
      <pubDate>Thu, 02 Sep 2021 09:08:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-value-with-single-quote/m-p/765582#M242511</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2021-09-02T09:08:06Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable value with single quote</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-value-with-single-quote/m-p/765586#M242512</link>
      <description>&lt;P&gt;If the SQL server accepts only single quotes for strings, use double quotes in the string.&lt;/P&gt;
&lt;P&gt;Or try to use 2 consecutive single quotes in the string, this might be possible.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Sep 2021 09:30:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-value-with-single-quote/m-p/765586#M242512</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-09-02T09:30:20Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable value with single quote</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-value-with-single-quote/m-p/765588#M242514</link>
      <description>&lt;P&gt;yes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As an example, please check that the following three sql statements all give the same result.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  call symput('rep_run',upcase("'closing run'' insurance','insurance','secondary closing run insurance','business insurance','RI_BCT'"));
run;

data test;
  length rep_run $30;
  rep_run="CLOSING RUN' INSURANCE";output;
  rep_run='CLOSING RUN'' INSURANCE';output;
  rep_run='RI_BC';output;
  rep_run='BUSINESS INSURANCE';output;
run;


Proc Sql ;
    Select rep_run
          ,(Case 
	         	When (rep_run) in (&amp;amp;rep_run.) 
		            then 'PI_PPT' 
	            else  ' '
	        end
            ) as x
    from test;

Proc Sql ;
    Select rep_run
          ,(Case 
	    	    When (rep_run) in ('CLOSING RUN'' INSURANCE'
                                  ,"BUSINESS INSURANCE"
                                  ,"INSURANCE"
                                  ,'RI_BCT')
		            then 'PI_PPT' 
	            else  ' '
	        end
            ) as x
    from test;

Proc Sql ;
    Select rep_run
          ,(Case 
	    	    When (rep_run) in ("CLOSING RUN' INSURANCE"
                                  ,"BUSINESS INSURANCE"
                                  ,"INSURANCE"
                                  ,'RI_BCT')
		            then 'PI_PPT' 
	            else  ' '
	        end
            ) as x
    from test;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Sep 2021 09:37:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-value-with-single-quote/m-p/765588#M242514</guid>
      <dc:creator>japelin</dc:creator>
      <dc:date>2021-09-02T09:37:43Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable value with single quote</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-value-with-single-quote/m-p/765593#M242516</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/226565"&gt;@japelin&lt;/a&gt;&amp;nbsp;your code is working fine with the SAS datasets but not with the SQL tables. I'm getting the similar error as I mentioned before.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;217        'CLOSING RUN(VFA)','SECONDARY CLOSING RUN,CLOSING RUN(BFA)','IMPACT OF OVERRETURN ON CPM,'BASELINE FOR INITAL                           ___                           ___                          ___                          ___
                           49                            49                           49                           49&lt;/PRE&gt;
&lt;P&gt;My program is&amp;nbsp;similar as below, but the source table is from SQL.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Proc Sql ;
    Select rep_run
          ,(Case 
	         	When (rep_run) in (&amp;amp;rep_run.) 
		            then 'PI_PPT' 
	            else  ' '
	        end
            ) as x
    from sqltbl.test;&lt;/PRE&gt;</description>
      <pubDate>Thu, 02 Sep 2021 10:25:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-value-with-single-quote/m-p/765593#M242516</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2021-09-02T10:25:16Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable value with single quote</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-value-with-single-quote/m-p/765595#M242518</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35763"&gt;@yabwon&lt;/a&gt;&amp;nbsp;How do you handle your second data step If I want to create multiple macro variables in the first data step as shown below?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data _null_;
  call symputx("rep_run", "closing run' insurance,insurance,secondary closing run insurance,business insurance,RI_BCT");
  call symputx("chk_run", "insurance,secondary closing run insurance,business insurance,PI_BCT");
  call symputx("chk_date_sql", "RI_TCT");
run;&lt;/PRE&gt;</description>
      <pubDate>Thu, 02 Sep 2021 10:35:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-value-with-single-quote/m-p/765595#M242518</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2021-09-02T10:35:14Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable value with single quote</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-value-with-single-quote/m-p/765596#M242519</link>
      <description>&lt;P&gt;How about a loop?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  call symputx("rep_run", "closing run' insurance,insurance,secondary closing run insurance,business insurance,RI_BCT");
  call symputx("chk_run", "insurance,secondary closing run insurance,business insurance,PI_BCT");
  call symputx("chk_date_sql", "RI_TCT");
run;
%put rep_run=%superq(rep_run);
%put chk_run=%superq(chk_run);
%put chk_date_sql=%superq(chk_date_sql);

data _null_;
  length text str rep_run $ 32767 x $ 32;

  do x = "rep_run","chk_run","chk_date_sql";
    text = symget(x);

      do _N_= 1 to countw(text, ",");
        str = scan(text, _N_, ",");
        rep_run = catx(",", rep_run, quote(upcase(strip(str)),"'"));
      end;

    call symputx(x, rep_run, "G");&lt;BR /&gt;    rep_run = " ";
  end;
run;
%put rep_run=%superq(rep_run);
%put chk_run=%superq(chk_run);
%put chk_date_sql=%superq(chk_date_sql);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Thu, 02 Sep 2021 10:47:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-value-with-single-quote/m-p/765596#M242519</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2021-09-02T10:47:12Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable value with single quote</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-value-with-single-quote/m-p/765601#M242520</link>
      <description>&lt;P&gt;&lt;EM&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35763"&gt;@yabwon&lt;/a&gt;&lt;/EM&gt;&amp;nbsp;Perfect.Your code is working fine. I have two more questions before I close this topic.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;- why there is a two single quote after the string 'CLOSING RUN. Have you noticed it?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;49         %put rep_run=%superq(rep_run);
rep_run='CLOSING RUN'' INSURANCE','INSURANCE','SECONDARY CLOSING RUN INSURANCE','BUSINESS INSURANCE','RI_BCT'&lt;/PRE&gt;
&lt;P&gt;&lt;EM&gt;- &lt;/EM&gt;Can we accomplish this task only by data step? any alternate methods?&lt;/P&gt;</description>
      <pubDate>Thu, 02 Sep 2021 11:39:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-value-with-single-quote/m-p/765601#M242520</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2021-09-02T11:39:05Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable value with single quote</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-value-with-single-quote/m-p/765625#M242528</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1) double single quote is to mask that one single quote "between" single quotes. Run the code and you will see that double single quote in code is converted into single one by the data.&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;data test;
  x = "ab'cd"; /* no need for escape */
  y = 'ab''cd'; /* escape ' by doubling it */
run;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;You do that kind of "escaping" when you are passing text data containing single quotes in Oracle or SQLserver.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In your macrovariable you had:&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;CLOSING RUN' INSURANCE&lt;/PRE&gt;
&lt;P&gt;so after adding single quotes around the text [we have the quote() function in the data step] that one inside had to be doubled.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2) Using data step in this case is more convenient because you don't have to worry about that "special characters".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;All the best&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Sep 2021 13:22:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-value-with-single-quote/m-p/765625#M242528</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2021-09-02T13:22:48Z</dc:date>
    </item>
  </channel>
</rss>

