<?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: Marco statement with an apostrophe in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Marco-statement-with-an-apostrophe/m-p/796622#M255647</link>
    <description>&lt;P&gt;Thank-you so much! This worked. And yes SAS session was in an unstable state and I had to save and reopen.&lt;/P&gt;</description>
    <pubDate>Wed, 16 Feb 2022 16:37:35 GMT</pubDate>
    <dc:creator>mtee15</dc:creator>
    <dc:date>2022-02-16T16:37:35Z</dc:date>
    <item>
      <title>Marco statement with an apostrophe</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Marco-statement-with-an-apostrophe/m-p/796612#M255641</link>
      <description>&lt;P&gt;%macro education(education, ORDER);&lt;BR /&gt;data education;&lt;BR /&gt;set history_education;&lt;/P&gt;&lt;P&gt;where education="&amp;amp;education";&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;%mend&lt;/P&gt;&lt;P&gt;%education(University Bachelor's,8)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Above is my macro but the apostrophe in Bachelor's isn't allow me to run this statement. Is there anyway around this?&lt;/P&gt;</description>
      <pubDate>Wed, 16 Feb 2022 16:15:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Marco-statement-with-an-apostrophe/m-p/796612#M255641</guid>
      <dc:creator>mtee15</dc:creator>
      <dc:date>2022-02-16T16:15:00Z</dc:date>
    </item>
    <item>
      <title>Re: Marco statement with an apostrophe</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Marco-statement-with-an-apostrophe/m-p/796615#M255642</link>
      <description>&lt;P&gt;Try below. Untested.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%education(%nrstr(University Bachelor's),8)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 16 Feb 2022 16:22:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Marco-statement-with-an-apostrophe/m-p/796615#M255642</guid>
      <dc:creator>ChanceTGardener</dc:creator>
      <dc:date>2022-02-16T16:22:33Z</dc:date>
    </item>
    <item>
      <title>Re: Marco statement with an apostrophe</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Marco-statement-with-an-apostrophe/m-p/796618#M255643</link>
      <description>&lt;P&gt;Use the %str function and "mask" the single unmatched apostrophe in the value.&lt;/P&gt;
&lt;P&gt;The example code below writes the parameter to the log:&lt;/P&gt;
&lt;PRE&gt;%macro dummy (parameter);
  %put the parameter is: &amp;amp;parameter.;
%mend;

%dummy(simple string)

%dummy(%str(text with problem%'s))

&lt;/PRE&gt;
&lt;P&gt;Note that you have very likely placed your SAS session into an unusable state and should save your code, shut down and restart SAS.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Feb 2022 16:24:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Marco-statement-with-an-apostrophe/m-p/796618#M255643</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-02-16T16:24:42Z</dc:date>
    </item>
    <item>
      <title>Re: Marco statement with an apostrophe</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Marco-statement-with-an-apostrophe/m-p/796622#M255647</link>
      <description>&lt;P&gt;Thank-you so much! This worked. And yes SAS session was in an unstable state and I had to save and reopen.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Feb 2022 16:37:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Marco-statement-with-an-apostrophe/m-p/796622#M255647</guid>
      <dc:creator>mtee15</dc:creator>
      <dc:date>2022-02-16T16:37:35Z</dc:date>
    </item>
    <item>
      <title>Re: Marco statement with an apostrophe</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Marco-statement-with-an-apostrophe/m-p/796641#M255661</link>
      <description>&lt;P&gt;The caller needs to protect the characters that cause issues for the macro language.&amp;nbsp; You will also have trouble with commas in the value of that parameter.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The easiest way to protect with macro quoting is the %BQUOTE() function as it will handle the unbalanced quotes.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%education(%bquote(University Bachelor's),8)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You could design your macro to assume the value is quoted already in the call.&amp;nbsp; And then because the value is quoted in the call the extra single quote does not cause any issues.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro education(education, ORDER);
data education;
  set history_education;
  where education=&amp;amp;education;
run;
%mend ;
%education("University Bachelor's",8)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You could even make the macro smart enough to add quotes if they are not already there, but the bottom line is it is the macro callers responsibility to type a command that SAS can parse.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Feb 2022 17:23:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Marco-statement-with-an-apostrophe/m-p/796641#M255661</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-02-16T17:23:44Z</dc:date>
    </item>
  </channel>
</rss>

