<?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 How to pass strings beginning with a space or containing commas to a macro? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-pass-strings-beginning-with-a-space-or-containing-commas/m-p/844700#M333943</link>
    <description>&lt;P&gt;I want to run a macro like this&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;%macro mymacro(str1, str2);
	data want;
		set have;
		if index(mystring, "&amp;amp;str1") &amp;gt; 0 or index(mystring, "&amp;amp;str2") &amp;gt; 0;
	run;
%mend&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The problem is that my input strings include cases like " FL", ",C A", ", DE", "G.A."&lt;/P&gt;&lt;P&gt;How can I safely pass these strings into the macro?&lt;/P&gt;</description>
    <pubDate>Wed, 16 Nov 2022 20:28:25 GMT</pubDate>
    <dc:creator>xyxu</dc:creator>
    <dc:date>2022-11-16T20:28:25Z</dc:date>
    <item>
      <title>How to pass strings beginning with a space or containing commas to a macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-pass-strings-beginning-with-a-space-or-containing-commas/m-p/844700#M333943</link>
      <description>&lt;P&gt;I want to run a macro like this&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;%macro mymacro(str1, str2);
	data want;
		set have;
		if index(mystring, "&amp;amp;str1") &amp;gt; 0 or index(mystring, "&amp;amp;str2") &amp;gt; 0;
	run;
%mend&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The problem is that my input strings include cases like " FL", ",C A", ", DE", "G.A."&lt;/P&gt;&lt;P&gt;How can I safely pass these strings into the macro?&lt;/P&gt;</description>
      <pubDate>Wed, 16 Nov 2022 20:28:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-pass-strings-beginning-with-a-space-or-containing-commas/m-p/844700#M333943</guid>
      <dc:creator>xyxu</dc:creator>
      <dc:date>2022-11-16T20:28:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass strings beginning with a space or containing commas to a macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-pass-strings-beginning-with-a-space-or-containing-commas/m-p/844706#M333945</link>
      <description>&lt;P&gt;Use an appropriate macro quoting funciton. See the blog post&amp;nbsp;Passing comma-delimited values into SAS macros and macro functions by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/51532"&gt;@LeonidBatkhan&lt;/a&gt;&amp;nbsp;for a thorough discussion.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Nov 2022 20:36:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-pass-strings-beginning-with-a-space-or-containing-commas/m-p/844706#M333945</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-11-16T20:36:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass strings beginning with a space or containing commas to a macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-pass-strings-beginning-with-a-space-or-containing-commas/m-p/844713#M333949</link>
      <description>&lt;P&gt;Here is the link to that post: &lt;A href="https://blogs.sas.com/content/sgf/2019/07/17/passing-comma-delimited-values-into-sas-macros-and-macro-functions/" target="_self"&gt;Passing comma-delimited values into SAS macros and macro functions&lt;/A&gt; .&lt;/P&gt;</description>
      <pubDate>Wed, 16 Nov 2022 21:02:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-pass-strings-beginning-with-a-space-or-containing-commas/m-p/844713#M333949</guid>
      <dc:creator>LeonidBatkhan</dc:creator>
      <dc:date>2022-11-16T21:02:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass strings beginning with a space or containing commas to a macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-pass-strings-beginning-with-a-space-or-containing-commas/m-p/844716#M333950</link>
      <description>&lt;P&gt;Probably the easiest way is to include the quote marks in the values you pass.&amp;nbsp; They will then protect the space and the comma.&amp;nbsp; e.g. :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro mymacro(str1, str2);
	data want;
		set have;
		if index(mystring, &amp;amp;str1) &amp;gt; 0 or index(mystring, &amp;amp;str2) &amp;gt; 0;
	run;
%mend ;

options mprint ; 
%mymacro(" FL",",C A")&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But certainly doing it via macro quoting will work.&amp;nbsp; And&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/51532"&gt;@LeonidBatkhan&lt;/a&gt;'s blog is a great place to start.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Nov 2022 21:21:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-pass-strings-beginning-with-a-space-or-containing-commas/m-p/844716#M333950</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2022-11-16T21:21:28Z</dc:date>
    </item>
  </channel>
</rss>

