<?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: Macro Variable Quoting in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Quoting/m-p/877542#M346658</link>
    <description>I get values from JavaScript. Javascript will get the values from Webpage&lt;BR /&gt;prompt selection.&lt;BR /&gt;</description>
    <pubDate>Thu, 25 May 2023 16:31:34 GMT</pubDate>
    <dc:creator>Babloo</dc:creator>
    <dc:date>2023-05-25T16:31:34Z</dc:date>
    <item>
      <title>Macro Variable Quoting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Quoting/m-p/877536#M346652</link>
      <description>&lt;P&gt;I've the macro variable value separated by commas. I want the each value to be enclosed with single quote while I use in program. Currently it's not working as it is enclosing with one quote for all the values instead of each value to be separated by single quote.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I cannot control the macro variable value in %let as it is being passed by other macro variable. I want to know how to add single quote in WHERE clause.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%let parameter=Data Management,Operations,Sales ;
proc print data=have noobs;
  where Division in ( "&amp;amp;parameter" ) ;  
run;
&lt;/PRE&gt;
&lt;P&gt;Log shows,&lt;/P&gt;
&lt;PRE&gt;where Division='Data Management,Operations,Sales';&lt;/PRE&gt;
&lt;P&gt;Excepted Result:&lt;/P&gt;
&lt;PRE&gt;Where Division= 'Data Management','Operations','Sales';&lt;/PRE&gt;
&lt;P&gt;Solution should handle if even there is one value or two values in the %let.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;E.g..&lt;/P&gt;
&lt;PRE&gt;%let parameter=Data Management;
%let parameter=Data Management,Operations;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 May 2023 15:48:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Quoting/m-p/877536#M346652</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2023-05-25T15:48:41Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable Quoting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Quoting/m-p/877537#M346653</link>
      <description>&lt;P&gt;If you need each value in a list to be in quotes then you really should make the variable that way.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%let parameter='Data Management','Operations','Sales' ;&lt;/PRE&gt;
&lt;P&gt;You also need to consider if you really really really need the commas. The macro processor uses commas to delimit parameters in a macro definition. So you may get unexpected (read runtime errors) if you have a macro attempting to use that macro variable as a parameter. Many functions will also treat the comma as a delimiter and require special handling as well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do also note that this is incorrect syntax:&lt;/P&gt;
&lt;PRE&gt;Where Division= 'Data Management','Operations','Sales';&lt;/PRE&gt;
&lt;P&gt;IN perhaps but never = to a list of items in SAS syntax. That is not what SAS would generate in the log either:&lt;/P&gt;
&lt;PRE&gt;162  %let namelist= 'Alice' 'Fred';
163
164  data want;
165     set sashelp.class;
166     where name in (&amp;amp;namelist.);
167  run;

NOTE: There were 1 observations read from the data set SASHELP.CLASS.
      WHERE name in ('Alice', 'Fred');
NOTE: The data set WORK.WANT has 1 observations and 5 variables.
&lt;/PRE&gt;
&lt;P&gt;You log shows = because there was only one value for the in operator to evaluate.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 May 2023 16:19:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Quoting/m-p/877537#M346653</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-05-25T16:19:24Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable Quoting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Quoting/m-p/877539#M346655</link>
      <description>&lt;P&gt;I strongly suspect that you won't be writing/rewriting the %LET every time you run such a program.&lt;/P&gt;
&lt;P&gt;From where do you get the values to populate the macro variable?&lt;/P&gt;</description>
      <pubDate>Thu, 25 May 2023 16:29:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Quoting/m-p/877539#M346655</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-05-25T16:29:19Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable Quoting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Quoting/m-p/877541#M346657</link>
      <description>While I agree with you, please note that I cannot control the values passed&lt;BR /&gt;to %let parameter.&lt;BR /&gt;&lt;BR /&gt;I'm puzzled how to resolve this issue now. Is there a way that we can&lt;BR /&gt;create another macro variable like %let parameter2 which should take value&lt;BR /&gt;from %let parameter and to add single quote to each value?&lt;BR /&gt;</description>
      <pubDate>Thu, 25 May 2023 16:29:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Quoting/m-p/877541#M346657</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2023-05-25T16:29:34Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable Quoting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Quoting/m-p/877542#M346658</link>
      <description>I get values from JavaScript. Javascript will get the values from Webpage&lt;BR /&gt;prompt selection.&lt;BR /&gt;</description>
      <pubDate>Thu, 25 May 2023 16:31:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Quoting/m-p/877542#M346658</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2023-05-25T16:31:34Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable Quoting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Quoting/m-p/877543#M346659</link>
      <description>&lt;P&gt;You can use the %QLIST macro to take your input string in &amp;amp;parameter and create a new macro variable with single quotes around each item in &amp;amp;parameter.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://github.com/sasutils/macros/blob/master/qlist.sas" target="_blank" rel="noopener"&gt;https://github.com/sasutils/macros/blob/master/qlist.sas&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 25 May 2023 16:37:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Quoting/m-p/877543#M346659</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-05-25T16:37:12Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable Quoting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Quoting/m-p/877544#M346660</link>
      <description>Aww, it's huge. It would be nice if it can be handled in much simpler way&lt;BR /&gt;in order for other team members also can understand.&lt;BR /&gt;</description>
      <pubDate>Thu, 25 May 2023 16:43:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Quoting/m-p/877544#M346660</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2023-05-25T16:43:34Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable Quoting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Quoting/m-p/877546#M346661</link>
      <description>That's because it's generic for multiple cases. If your case is always this, go through and remove the parameters not needed and conditions not needed.</description>
      <pubDate>Thu, 25 May 2023 16:45:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Quoting/m-p/877546#M346661</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-05-25T16:45:30Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable Quoting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Quoting/m-p/877549#M346664</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then use a simple data step to get the quoted list:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
length target $32767;
source = "&amp;amp;parameter.";
do i = 1 to countw(source,",");
  target = catx(",",target,quote(scan(source,i,",")));
end;
call symputx('parameter',target,'g');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Later, use&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;in (&amp;amp;parameter.)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 May 2023 16:48:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Quoting/m-p/877549#M346664</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-05-25T16:48:57Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable Quoting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Quoting/m-p/877556#M346668</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/8409"&gt;@Babloo&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Aww, it's huge. It would be nice if it can be handled in much simpler way&lt;BR /&gt;in order for other team members also can understand.&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;While I understand why your other team members might need to understand your code, I don't understand the "it's huge" part. The code behind PROC SQL is huge as well, but you use it. The code behind PROC MEANS is huge, but you use it. And it gets the job done quickly, one line of code to %include the macro and one more line of code to call it and get the single quotes the way you want doesn't seem to be too burdensome.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And a well commented program makes it much easier for others to understand, even if they have never seen %qlist before.&lt;/P&gt;</description>
      <pubDate>Thu, 25 May 2023 16:56:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Quoting/m-p/877556#M346668</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-05-25T16:56:58Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable Quoting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Quoting/m-p/877562#M346672</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/8409"&gt;@Babloo&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;I get values from JavaScript. Javascript will get the values from Webpage&lt;BR /&gt;prompt selection.&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Who wrote the Javascript and the Web Form?&amp;nbsp; Have them fix it so instead of returning NAME when you pick NAME from the user interface it returns 'NAME'.&amp;nbsp; &amp;nbsp;Web forms do that type of thing all of the time.&amp;nbsp; The user picks between Yes and No and the form returns Y or N, or perhaps 1 or 0.&amp;nbsp; It should be a trivial change to the Javascript.&lt;/P&gt;</description>
      <pubDate>Thu, 25 May 2023 17:15:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Quoting/m-p/877562#M346672</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-05-25T17:15:44Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable Quoting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Quoting/m-p/877567#M346675</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*source macro code - or download and maintain the code*/
filename qlist url 'https://raw.githubusercontent.com/sasutils/macros/master/qlist.sas';
%include  qlist;

%let varlist = Data Management,Operations,Sales; 

%let my_list= %qlist(%quote(&amp;amp;varlist.), paren=0, comma=1, delimit=',', dsd = 0, quote=2);

%put &amp;amp;my_list.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 May 2023 19:02:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Quoting/m-p/877567#M346675</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-05-25T19:02:38Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable Quoting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Quoting/m-p/877571#M346677</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/8409"&gt;@Babloo&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I typically do the following to quote separated values within a macro variable&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let parameter=Data Management,Operations,Sales;
%put &amp;amp;=parameter;
%let parameter=%str(%')%qsysfunc(tranwrd(&amp;amp;parameter,%str(,), %str(%',%')))%str(%');
%put &amp;amp;=parameter;

/* To use this macro variable in a where clause, I would use %unquote() */
Where Division in (%unquote(&amp;amp;parameter));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Hope this helps&lt;/P&gt;</description>
      <pubDate>Thu, 25 May 2023 17:57:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Quoting/m-p/877571#M346677</guid>
      <dc:creator>AhmedAl_Attar</dc:creator>
      <dc:date>2023-05-25T17:57:14Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable Quoting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Quoting/m-p/877608#M346688</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/8409"&gt;@Babloo&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Aww, it's huge. It would be nice if it can be handled in much simpler way&lt;BR /&gt;in order for other team members also can understand.&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This might be a good time to introduce your team to the benefits of having a shared autocall macro library which stores the definitions for general-purpose macros.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your team has people writing macros, they will probably agree that many macro language use-cases involve lists.&amp;nbsp; I have a list of variables, and I want to loop over them.&amp;nbsp; Or a list of datasets.&amp;nbsp; Or list of whatever.&amp;nbsp; Often you want to do something to each item of the list, sometimes you want to generate a different list.&amp;nbsp; Maybe it's a list with the each item in quotes, or a list with a different delimiter, or a list where each item has&amp;nbsp; prefix or suffix added to it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Once you see that this is a general problem of list modification, having a general macro you can call for list manipulation is very handy, and reduces the amount of code you need to write.&amp;nbsp; The function-style macro hides the code.&amp;nbsp; So whether you use %qlist, or Richard DeVenezia's %seplist (&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;), or something similar, if your team members are going to be using the macro language, it's worth taking the time to understand how function-style macros can make your life easier.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This 1 1/2 page paper by Peter Crawford is my favorite introduction to function-style macros.&amp;nbsp; It features a one-line macro.&amp;nbsp;&amp;nbsp;&lt;A href="https://support.sas.com/resources/papers/proceedings/proceedings/sugi31/038-31.pdf" target="_blank"&gt;https://support.sas.com/resources/papers/proceedings/proceedings/sugi31/038-31.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 May 2023 20:30:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Quoting/m-p/877608#M346688</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2023-05-25T20:30:50Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable Quoting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Quoting/m-p/877629#M346696</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 tried your code and it's almost fine. One issue is ending quote is displaying in next line. I'm not certain about the likely cause for the issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;E.g.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"107171-003&lt;/P&gt;
&lt;P&gt;"&lt;/P&gt;
&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Log:&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;18   data _null_;
19   length target $32767;
20   source = "&amp;amp;parameter.";
SYMBOLGEN:  Macro variable parameter resolves to 107171-003
21   do i = 1 to countw(source,",");
22     target = catx(",",target,quote(scan(source,i,",")));
23   end;
24   call symputx('parameter',target,'g');
25   run;

NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds                                    

SYMBOLGEN:  Macro variable parameter resolves to "107171-003

"
26   
27   %put ####parameter is: &amp;amp;parameter.;
####parameter is: "107171-003

"
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 May 2023 04:39:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Quoting/m-p/877629#M346696</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2023-05-26T04:39:35Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable Quoting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Quoting/m-p/877632#M346699</link>
      <description>&lt;P&gt;It is likely the extra characters were in the source string.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That is the nature of fixed length strings used by data step.&lt;/P&gt;
&lt;P&gt;If variable SOURCE is defined to be length 20 and you assign the value "107171-003" to then it will have 10 spaces added to fill it out to the full 20.&lt;/P&gt;
&lt;P&gt;So when you use SCAN() to find the first word when delimited by comma it takes all 20 characters.&lt;/P&gt;
&lt;P&gt;Which when passed to QUOTE() means you get back a string that is 22 characters long once the opening a closing quotes are added.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use the TRIM() function to remove trailing spaces.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;target = catx(",",target,quote(trim(scan(source,i,","))));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or replace TRIM() with STRIP() if you also want to remove leading spaces from values like "107171-003,&amp;nbsp; &amp;nbsp;10717-004"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 May 2023 04:51:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Quoting/m-p/877632#M346699</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-05-26T04:51:24Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable Quoting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Quoting/m-p/877637#M346702</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;I tried your code and still the issue persists.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;  data _null_;
19   length target $32767;
20   source = "&amp;amp;parameter.";
SYMBOLGEN:  Macro variable PARAMETER resolves to SALES-100A-TS
21   do i = 1 to countw(source,",");
22   /*   target = catx(",",target,quote(scan(source,i,","))); */
23     target = catx(",",target,quote(trim(scan(source,i,","))));
24   end;
25   call symputx('parameter',target,'g');
26   run;

NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

SYMBOLGEN:  Macro variable PARAMETER resolves to "SALES-100A-TS

"
27   
28   %put ####PARAMETER is: &amp;amp;parameter.;
####PARAMETER is: "SALES-100A-TS

"&lt;/PRE&gt;</description>
      <pubDate>Fri, 26 May 2023 05:21:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Quoting/m-p/877637#M346702</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2023-05-26T05:21:48Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable Quoting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Quoting/m-p/877638#M346703</link>
      <description>&lt;P&gt;So you have some extra stuff in the parameter. Get to Know Your Data (Maxim 3):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
length target $32767;
source = "&amp;amp;parameter.";
do i = 1 to countw(source,",");
  word = scan(source,i,",");
  put word $hex30.; * increase format width if needed;
  * later, add use of COMPRESS to get rid of unwanted special characters;
  target = catx(",",target,quote(trim(word)));
end;
call symputx('parameter',target,'g');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 May 2023 05:38:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Quoting/m-p/877638#M346703</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-05-26T05:38:10Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable Quoting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Quoting/m-p/877655#M346707</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; Any other solution without using $hex format?&lt;/P&gt;</description>
      <pubDate>Fri, 26 May 2023 09:07:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Quoting/m-p/877655#M346707</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2023-05-26T09:07:29Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable Quoting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Quoting/m-p/877671#M346711</link>
      <description>It is the easiest way to find out which invisible characters are causing unwanted effects.</description>
      <pubDate>Fri, 26 May 2023 10:57:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Quoting/m-p/877671#M346711</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-05-26T10:57:30Z</dc:date>
    </item>
  </channel>
</rss>

