<?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 Quetion in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-Quetion/m-p/870629#M343867</link>
    <description>&lt;P&gt;You should probably clean up the HTML definitions for the selection list so that it generates a string that does not have unbalanced quotes or unquoted macro triggers like &amp;amp; or %.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 19 Apr 2023 19:38:39 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2023-04-19T19:38:39Z</dc:date>
    <item>
      <title>Macro Quetion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Quetion/m-p/870603#M343848</link>
      <description>&lt;P&gt;I have following macro variable :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let NAME= NAME=Carlotta's Kitchen LLC,Chan &amp;amp; Chan (USA) Inc.,Cle-Mor Market,Clint &amp;amp; Sons Beef Jerky,D&amp;amp;D Foods Inc.,D.I.M. Inc;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How can create a Name_List macro from Name macro as shown below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Name_List = 'Carlotta's Kitchen LLC','Chan &amp;amp; Chan (USA) Inc.','Cle-Mor Market,Clint &amp;amp; Sons Beef Jerky','D&amp;amp;D Foods Inc.','D.I.M. Inc';&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried as&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%global&amp;nbsp;NAME&amp;nbsp;Name_List;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%Macro Name_LIST;&lt;BR /&gt;%let Name_LIST =;&lt;BR /&gt;&lt;BR /&gt;%let count=%sysfunc(countw(%bquote(&amp;amp;NAME),%str(,)));&lt;BR /&gt;%put &amp;amp;count;&lt;BR /&gt;%do i=1 %to &amp;amp;count;&lt;BR /&gt;%let Name_LIST =%qsysfunc(tranwrd(&amp;amp;Name_LIST %str(%')%scan(%bquote(&amp;amp;NAME),&amp;amp;i,%str(,))%str(%'), &lt;BR /&gt;%str( ),%str(, )));&lt;BR /&gt;%end;&lt;BR /&gt;&lt;BR /&gt;%Mend;&lt;BR /&gt;&lt;BR /&gt;%Name_LIST&lt;BR /&gt;%let Name_LIST = %superq(Name_LIST);&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Apr 2023 17:30:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Quetion/m-p/870603#M343848</guid>
      <dc:creator>GPatel</dc:creator>
      <dc:date>2023-04-19T17:30:56Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Quetion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Quetion/m-p/870607#M343850</link>
      <description>&lt;P&gt;Do it with datastep:&lt;/P&gt;
&lt;P&gt;1) symget() to store macrovaraible in a variable&lt;/P&gt;
&lt;P&gt;2) do-loop with scan(,i,",") witch comma as separator&lt;/P&gt;
&lt;P&gt;3) use quote(,) function to add quotes,&lt;/P&gt;
&lt;P&gt;4) combine it in 1 string with catx(",",....)&lt;/P&gt;
&lt;P&gt;and&lt;/P&gt;
&lt;P&gt;5) call symputX() to push to macroworld again.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Apr 2023 17:37:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Quetion/m-p/870607#M343850</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2023-04-19T17:37:07Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Quetion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Quetion/m-p/870610#M343852</link>
      <description>&lt;P&gt;I'm a fan of Richard DeVenezia's %seplist() macro for adding delimiters, quotes, etc to lists of items.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&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;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What you've got is a nasty macro quoting puzzle, which usually can be avoided, but as long as you quote the value, %seplist willl keep it quoted.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_ ;
  call symputx("namelist",'Carlotta''s Kitchen LLC,Chan &amp;amp; Chan (USA) Inc.,Cle-Mor Market,Clint &amp;amp; Sons Beef Jerky,D&amp;amp;D Foods Inc.,D.I.M. Inc') ;
run ;
%put namelist=%superq(namelist) ;

%let namelist2= %seplist(%superq(namelist),nest=Q,indlm=%str(,)) ;
%put namelist2=&amp;amp;namelist2 ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Returns:&lt;/P&gt;
&lt;PRE&gt;1    data _null_ ;
2      call symputx("namelist",'Carlotta''s Kitchen LLC,Chan &amp;amp; Chan (USA) Inc.,Cle-Mor Market,Clint &amp;amp;
2  ! Sons Beef Jerky,D&amp;amp;D Foods Inc.,D.I.M. Inc') ;
3    run ;


4    %put namelist=%superq(namelist) ;
namelist=Carlotta's Kitchen LLC,Chan &amp;amp; Chan (USA) Inc.,Cle-Mor Market,Clint &amp;amp; Sons Beef Jerky,D&amp;amp;D
Foods Inc.,D.I.M. Inc
5
6    %let namelist2= %seplist(%superq(namelist),nest=Q,indlm=%str(,)) ;
7    %put namelist2=&amp;amp;namelist2 ;
namelist2='Carlotta's Kitchen LLC','Chan &amp;amp; Chan (USA) Inc.','Cle-Mor Market','Clint &amp;amp; Sons Beef
Jerky','D&amp;amp;D Foods Inc.','D.I.M. Inc'
&lt;/PRE&gt;
&lt;P&gt;It doesn't remove the macro quoting, doesn't try to resolve any masked macro tokens, and doesn't get tripped up by the unmatched single quote.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Apr 2023 17:57:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Quetion/m-p/870610#M343852</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2023-04-19T17:57:43Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Quetion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Quetion/m-p/870611#M343853</link>
      <description>&lt;P&gt;How did you create that macro variable with the unbalanced quotes to begin with?&lt;/P&gt;
&lt;P&gt;What are you doing to do with the cleaned up macro variable that looks like that?&lt;/P&gt;
&lt;P&gt;Why not just leave the data in a dataset?&lt;/P&gt;</description>
      <pubDate>Wed, 19 Apr 2023 18:00:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Quetion/m-p/870611#M343853</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-04-19T18:00:25Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Quetion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Quetion/m-p/870615#M343856</link>
      <description>&lt;P&gt;Don't use macro code to work with messy strings.&amp;nbsp; Use SAS code instead.&lt;/P&gt;
&lt;PRE&gt;478  data _null_;
479    call symputx('name'
480  ,'NAME=Carlotta''s Kitchen LLC,Chan &amp;amp; Chan (USA) Inc.,Cle-Mor Market,Clint &amp;amp; Sons Beef Jerky,D&amp;amp;D Foods Inc.,D.I.M. Inc'
481  );
482
483  run;

NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


484
485  %put %superq(name);
NAME=Carlotta's Kitchen LLC,Chan &amp;amp; Chan (USA) Inc.,Cle-Mor Market,Clint &amp;amp; Sons Beef Jerky,D&amp;amp;D Foods Inc.,D.I.M. Inc
486
487  data _null_;
488    length old new $32767;
489    old=symget('name');
490    old=left(substr(old,index(old,'=')+1));
491    do i=1 to countw(old,',');
492      new=catx(',',new,quote(strip(scan(old,i,',')),"'"));
493    end;
494    call symputx('name_list',new);
495  run;

NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


496
497  %put &amp;amp;name_list;
'Carlotta''s Kitchen LLC','Chan &amp;amp; Chan (USA) Inc.','Cle-Mor Market','Clint &amp;amp; Sons Beef Jerky','D&amp;amp;D Foods Inc.','D.I.M. Inc'

&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Apr 2023 18:07:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Quetion/m-p/870615#M343856</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-04-19T18:07:45Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Quetion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Quetion/m-p/870620#M343860</link>
      <description>&lt;P&gt;To All:&lt;/P&gt;
&lt;P&gt;I have a HTML page with drop down (developed with JSON file)&amp;nbsp; to select name(s) . Once User selects one or more name from the drop down list, it creates a macro variable.&lt;/P&gt;
&lt;P&gt;Then, I use this macro variable to filter / subset the records from the dataset - user choice of names - for reporting activities.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards, GPATEL&lt;/P&gt;</description>
      <pubDate>Wed, 19 Apr 2023 19:08:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Quetion/m-p/870620#M343860</guid>
      <dc:creator>GPatel</dc:creator>
      <dc:date>2023-04-19T19:08:10Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Quetion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Quetion/m-p/870629#M343867</link>
      <description>&lt;P&gt;You should probably clean up the HTML definitions for the selection list so that it generates a string that does not have unbalanced quotes or unquoted macro triggers like &amp;amp; or %.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Apr 2023 19:38:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Quetion/m-p/870629#M343867</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-04-19T19:38:39Z</dc:date>
    </item>
  </channel>
</rss>

