<?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: change multiple quote with single quote from macro variabile in SAS Studio</title>
    <link>https://communities.sas.com/t5/SAS-Studio/change-multiple-quote-with-single-quote-from-macro-variabile/m-p/873462#M10931</link>
    <description>&lt;P&gt;I think you don't need data step inside the macro:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro foo(a);
%qsysfunc(translate(%superq(a),%str(%'),%str(%")))
%mend;

%put %foo(%str("A", "B", "C"));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
    <pubDate>Tue, 02 May 2023 18:49:22 GMT</pubDate>
    <dc:creator>yabwon</dc:creator>
    <dc:date>2023-05-02T18:49:22Z</dc:date>
    <item>
      <title>change multiple quote with single quote from macro variabile</title>
      <link>https://communities.sas.com/t5/SAS-Studio/change-multiple-quote-with-single-quote-from-macro-variabile/m-p/873394#M10920</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have this macro:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;%macro list;
"AAA",
"BBB",
"CCC"
%mend;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;and I want to change multiple quote (") with single (').&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you help me?&lt;/P&gt;&lt;P&gt;Thanks&amp;nbsp;&lt;/P&gt;&lt;P&gt;Luca&lt;/P&gt;</description>
      <pubDate>Tue, 02 May 2023 15:07:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/change-multiple-quote-with-single-quote-from-macro-variabile/m-p/873394#M10920</guid>
      <dc:creator>luca87</dc:creator>
      <dc:date>2023-05-02T15:07:44Z</dc:date>
    </item>
    <item>
      <title>Re: change multiple quote with single quote from macro variabile</title>
      <link>https://communities.sas.com/t5/SAS-Studio/change-multiple-quote-with-single-quote-from-macro-variabile/m-p/873397#M10921</link>
      <description>&lt;P&gt;Hmm, LIST is a reserved name, so you can't have such a macro : )&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;1    %macro list;
ERROR: Macro LIST has been given a reserved name.
ERROR: A dummy macro will be compiled.
2    "AAA",
3    "BBB",
4    "CCC"
5    %mend;
6
7    %put %list() ;
ERROR: Statement is followed by extraneous characters (. %LIST should be followed by a line number,
       line numbers separated with : or -, or a semicolon.
&lt;/PRE&gt;
&lt;P&gt;It would be unusual to use a macro to store only a list.&amp;nbsp; It's more common to use a macro variable:&lt;/P&gt;
&lt;PRE&gt;1    %let list=
2    "AAA",
3    "BBB",
4    "CCC"
5    ;
6
7    %put my list is: &amp;amp;list ;
my list is: "AAA", "BBB", "CCC"
&lt;/PRE&gt;
&lt;P&gt;Do you really have&amp;nbsp; macro that generates a list, or do you have a macro variable?&lt;/P&gt;</description>
      <pubDate>Tue, 02 May 2023 15:16:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/change-multiple-quote-with-single-quote-from-macro-variabile/m-p/873397#M10921</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2023-05-02T15:16:28Z</dc:date>
    </item>
    <item>
      <title>Re: change multiple quote with single quote from macro variabile</title>
      <link>https://communities.sas.com/t5/SAS-Studio/change-multiple-quote-with-single-quote-from-macro-variabile/m-p/873403#M10922</link>
      <description>&lt;P&gt;Sorry I change the name in the post but the real name of the macro is list_parameters.&lt;/P&gt;&lt;P&gt;I know that&amp;nbsp;&lt;SPAN&gt;It is unusual but I start from another process that produce this list that I can't chage.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Luca&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 02 May 2023 15:20:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/change-multiple-quote-with-single-quote-from-macro-variabile/m-p/873403#M10922</guid>
      <dc:creator>luca87</dc:creator>
      <dc:date>2023-05-02T15:20:52Z</dc:date>
    </item>
    <item>
      <title>Re: change multiple quote with single quote from macro variabile</title>
      <link>https://communities.sas.com/t5/SAS-Studio/change-multiple-quote-with-single-quote-from-macro-variabile/m-p/873405#M10923</link>
      <description>&lt;P&gt;Where are you planning to use this macro? Data step? PROC? Somewhere else? Can you provide a wee bit of code where this macro would be used?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What situations arise where "AAA" can't be used but 'AAA' is okay?&lt;/P&gt;</description>
      <pubDate>Tue, 02 May 2023 15:29:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/change-multiple-quote-with-single-quote-from-macro-variabile/m-p/873405#M10923</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-05-02T15:29:48Z</dc:date>
    </item>
    <item>
      <title>Re: change multiple quote with single quote from macro variabile</title>
      <link>https://communities.sas.com/t5/SAS-Studio/change-multiple-quote-with-single-quote-from-macro-variabile/m-p/873407#M10924</link>
      <description>&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;I need to use the information of the macro in a format native of teradata which not accept multiple quotation marks but single ones&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 02 May 2023 15:36:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/change-multiple-quote-with-single-quote-from-macro-variabile/m-p/873407#M10924</guid>
      <dc:creator>luca87</dc:creator>
      <dc:date>2023-05-02T15:36:01Z</dc:date>
    </item>
    <item>
      <title>Re: change multiple quote with single quote from macro variabile</title>
      <link>https://communities.sas.com/t5/SAS-Studio/change-multiple-quote-with-single-quote-from-macro-variabile/m-p/873414#M10925</link>
      <description>&lt;P&gt;Generally I don't put quotes around items in my lists, and I will use a macro like Richard DeVenezia's excellent %SepList&amp;nbsp;&amp;nbsp;&lt;A href="https://www.devenezia.com/downloads/sas/macros/index.php?m=seplist" target="_blank"&gt;https://www.devenezia.com/downloads/sas/macros/index.php?m=seplist&lt;/A&gt;&amp;nbsp;to add quotes or change delimiters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But for a quick replacement of quotes, you can use TRANSTRN or similar, you just have to dive down the macro quoting rabbit hole...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro list_parameters();
"AAA",
"BBB",
"CCC"
%mend;

%put my list is: %unquote(%sysfunc(transtrn(%bquote(%list_parameters()),%str(%"),%str(%')))) ;&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;Returns:&lt;/P&gt;
&lt;PRE&gt;21   %macro list_parameters();
22   "AAA",
23   "BBB",
24   "CCC"
25   %mend;
26
27   %put my list is: %unquote(%sysfunc(transtrn(%bquote(%list_parameters()),%str(%"),%str(%')))) ;
my list is: 'AAA', 'BBB', 'CCC'
&lt;/PRE&gt;
&lt;P&gt;The %unquote() may not be needed, but sometimes SAS doesn't %unquote automatically and things break.&lt;/P&gt;</description>
      <pubDate>Tue, 02 May 2023 15:48:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/change-multiple-quote-with-single-quote-from-macro-variabile/m-p/873414#M10925</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2023-05-02T15:48:36Z</dc:date>
    </item>
    <item>
      <title>Re: change multiple quote with single quote from macro variabile</title>
      <link>https://communities.sas.com/t5/SAS-Studio/change-multiple-quote-with-single-quote-from-macro-variabile/m-p/873415#M10926</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro listas;
"AAA",
"BBB",
"CCC"
%mend;

%put %sysfunc(quote(%sysfunc(dequote(%quote(%listas))),%str(%')));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 02 May 2023 15:50:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/change-multiple-quote-with-single-quote-from-macro-variabile/m-p/873415#M10926</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-05-02T15:50:41Z</dc:date>
    </item>
    <item>
      <title>Re: change multiple quote with single quote from macro variabile</title>
      <link>https://communities.sas.com/t5/SAS-Studio/change-multiple-quote-with-single-quote-from-macro-variabile/m-p/873418#M10927</link>
      <description>&lt;P&gt;If the macro generates a string that is longer than 64K bytes you will have trouble using it with macro functions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But you could easily use it with a data step in this way.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename code temp;
data _null_;
  length value $200 ;
  file code;
  put '%macro list_participants_sq;';
  any=0;
  do value=%list_participants;
    value=quote(trim(value),"'");
    if any then put ',';
    put value +(-1) @;
    any=1;
  end;
  put '%mend;';
run;
%include code ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;1    %macro list_participants;
2    "Abc",
3    "  xyz",
4    "Don't know"
5    %mend;
6    %put %list_participants;
"Abc", "  xyz", "Don't know"
7
8    filename code temp;
9    data _null_;
10     length value $200 ;
11     file code;
12     put '%macro list_participants_sq;';
13     any=0;
14     do value=%list_participants;
15       value=quote(trim(value),"'");
16       if any then put ',';
17       put value +(-1) @;
18       any=1;
19     end;
20     put '%mend;';
21   run;

NOTE: The file CODE is: .....

NOTE: 4 records were written to the file CODE.
      The minimum record length was 6.
      The maximum record length was 28.
NOTE: DATA statement used (Total process time):
      real time           0.02 seconds
      cpu time            0.03 seconds


22   %include code ;
27
28   %put %list_participants;
"Abc", "  xyz", "Don't know"
29   %put %list_participants_sq;
'Abc', '  xyz', 'Don''t know'
&lt;/PRE&gt;</description>
      <pubDate>Tue, 02 May 2023 16:00:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/change-multiple-quote-with-single-quote-from-macro-variabile/m-p/873418#M10927</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-05-02T16:00:15Z</dc:date>
    </item>
    <item>
      <title>Re: change multiple quote with single quote from macro variabile</title>
      <link>https://communities.sas.com/t5/SAS-Studio/change-multiple-quote-with-single-quote-from-macro-variabile/m-p/873419#M10928</link>
      <description>Something like&lt;BR /&gt;%macro foo(a);&lt;BR /&gt;data _null_;&lt;BR /&gt;b = %sysfunc (translate (&amp;amp;a,%str(%'),%str(%")));&lt;BR /&gt;set;&lt;BR /&gt;%mend;&lt;BR /&gt; &lt;BR /&gt;%foo(a = %str(("A", "B", "C"));&lt;BR /&gt;%put b;&lt;BR /&gt; 'A', 'B', 'C'&lt;BR /&gt;(this is "under-baked", still some errors)&lt;BR /&gt;see also here:&lt;BR /&gt;&lt;A href="https://marc.info/?l=sas-l&amp;amp;m=116624823380265&amp;amp;w=2" target="_blank"&gt;https://marc.info/?l=sas-l&amp;amp;m=116624823380265&amp;amp;w=2&lt;/A&gt;</description>
      <pubDate>Tue, 02 May 2023 16:00:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/change-multiple-quote-with-single-quote-from-macro-variabile/m-p/873419#M10928</guid>
      <dc:creator>pink_poodle</dc:creator>
      <dc:date>2023-05-02T16:00:35Z</dc:date>
    </item>
    <item>
      <title>Re: change multiple quote with single quote from macro variabile</title>
      <link>https://communities.sas.com/t5/SAS-Studio/change-multiple-quote-with-single-quote-from-macro-variabile/m-p/873433#M10929</link>
      <description>&lt;P&gt;I am struck by the thought that the problem is really in the creation of this string with double-quotes. However this string is being created, that's where you need to change so that it has single quotes. This seems much easier and much more logical than creating strings with double quotes and then changing the quotes to single quotes.&lt;/P&gt;</description>
      <pubDate>Tue, 02 May 2023 16:55:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/change-multiple-quote-with-single-quote-from-macro-variabile/m-p/873433#M10929</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-05-02T16:55:31Z</dc:date>
    </item>
    <item>
      <title>Re: change multiple quote with single quote from macro variabile</title>
      <link>https://communities.sas.com/t5/SAS-Studio/change-multiple-quote-with-single-quote-from-macro-variabile/m-p/873460#M10930</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/19879"&gt;@Quentin&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are plenty nice solutions to the question, but I can't help myself and share one which uses SAS Packages and SAS Packages Framework.&lt;/P&gt;
&lt;P&gt;Enable the framework, install, and load MacroArray package:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename packages "%sysfunc(pathname(work))"; /* setup WORK as temporary directory for packages */
filename SPFinit url "https://raw.githubusercontent.com/yabwon/SAS_PACKAGES/main/SPF/SPFinit.sas";
%include SPFinit; /* enable the framework */

%installPackage(macroArray) /* install macroArray package */
%loadPackage(macroArray)    /* load the package content into the SAS session */

/*
%helpPackage(macroArray,'%array()')
%helpPackage(macroArray,'%do_over()')
*/&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Use %array() and %do_over() macros:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
run;

%macro list_parameters();
"AAA",
"BBB",
"CCC"
%mend;

%array(myQlist[3] $ 12 (%list_parameters()), function=quote(strip(myQlist(_I_)), "'"), macarray=Y);

%let singleQuoted_list = %do_over(myQlist,between=%str(,));

%put &amp;amp;=singleQuoted_list.;

data _null_;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;(data steps are just "markers")&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Tue, 02 May 2023 18:39:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/change-multiple-quote-with-single-quote-from-macro-variabile/m-p/873460#M10930</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2023-05-02T18:39:15Z</dc:date>
    </item>
    <item>
      <title>Re: change multiple quote with single quote from macro variabile</title>
      <link>https://communities.sas.com/t5/SAS-Studio/change-multiple-quote-with-single-quote-from-macro-variabile/m-p/873462#M10931</link>
      <description>&lt;P&gt;I think you don't need data step inside the macro:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro foo(a);
%qsysfunc(translate(%superq(a),%str(%'),%str(%")))
%mend;

%put %foo(%str("A", "B", "C"));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Tue, 02 May 2023 18:49:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/change-multiple-quote-with-single-quote-from-macro-variabile/m-p/873462#M10931</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2023-05-02T18:49:22Z</dc:date>
    </item>
  </channel>
</rss>

