<?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: How to add single quote to a macro variable outside macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Re-How-to-add-single-quote-to-a-macro-variable-outside-macro/m-p/822845#M324915</link>
    <description>&lt;P&gt;Quotes (especially unbalanced quotes) are VERY dangerous in macro variables, as they will always trick the SAS interpreter into thinking that the string goes on and on, unless you are EXTREMELY diligent in using tools to mask the quote.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What do you try to do with this macro variable later on?&lt;/P&gt;</description>
    <pubDate>Tue, 12 Jul 2022 14:06:13 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2022-07-12T14:06:13Z</dc:date>
    <item>
      <title>Re: How to add single quote to a macro variable outside macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Re-How-to-add-single-quote-to-a-macro-variable-outside-macro/m-p/822814#M324899</link>
      <description>Data _null_&lt;BR /&gt;Call symput ('Month',put(intnx('month',today(),-2,'B'),monname.));&lt;BR /&gt;%put &amp;amp;month1. "22&lt;BR /&gt;While resolving macro variable month1 i want "22 ( single quite and 22 ) at the end of macro variable how i can add ?</description>
      <pubDate>Tue, 12 Jul 2022 12:27:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Re-How-to-add-single-quote-to-a-macro-variable-outside-macro/m-p/822814#M324899</guid>
      <dc:creator>Aniruddhaanu</dc:creator>
      <dc:date>2022-07-12T12:27:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to add single quote to a macro variable outside macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Re-How-to-add-single-quote-to-a-macro-variable-outside-macro/m-p/822822#M324902</link>
      <description>&lt;P&gt;Could you please fix the syntax errors in your code, which does not run at all.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It seems as if you are creating a month name, but then you say&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;While resolving macro variable month1 i want "22 ( single quite and 22 ) at the end of macro variable how i can add ?&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;and this doesn't make sense to me as a month name will never yield "22 when a quote is put in front of the month name.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jul 2022 13:01:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Re-How-to-add-single-quote-to-a-macro-variable-outside-macro/m-p/822822#M324902</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-07-12T13:01:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to add single quote to a macro variable outside macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Re-How-to-add-single-quote-to-a-macro-variable-outside-macro/m-p/822840#M324911</link>
      <description>Actually I want in mail that ,this is data of May"22.&lt;BR /&gt;&lt;BR /&gt;I have checked no syntax error there.&lt;BR /&gt;Even i can Abe to create May_22 variable but unable to create May"22&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 12 Jul 2022 13:54:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Re-How-to-add-single-quote-to-a-macro-variable-outside-macro/m-p/822840#M324911</guid>
      <dc:creator>Aniruddhaanu</dc:creator>
      <dc:date>2022-07-12T13:54:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to add single quote to a macro variable outside macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Re-How-to-add-single-quote-to-a-macro-variable-outside-macro/m-p/822845#M324915</link>
      <description>&lt;P&gt;Quotes (especially unbalanced quotes) are VERY dangerous in macro variables, as they will always trick the SAS interpreter into thinking that the string goes on and on, unless you are EXTREMELY diligent in using tools to mask the quote.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What do you try to do with this macro variable later on?&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jul 2022 14:06:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Re-How-to-add-single-quote-to-a-macro-variable-outside-macro/m-p/822845#M324915</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-07-12T14:06:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to add single quote to a macro variable outside macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Re-How-to-add-single-quote-to-a-macro-variable-outside-macro/m-p/822848#M324917</link>
      <description>&lt;P&gt;You can create a format that automatically includes the quote and year:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
picture mydate
  low-high = '%b"%0y' (datatype=date)
;
run;

data _null_;
call symput ('Month',put(intnx('month',today(),-2,'B'),mydate.));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or you add the quote in the original step:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;call symput ('Month',put(intnx('month',today(),-2,'B'),monname.)!!'"22');&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 12 Jul 2022 14:10:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Re-How-to-add-single-quote-to-a-macro-variable-outside-macro/m-p/822848#M324917</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-07-12T14:10:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to add single quote to a macro variable outside macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Re-How-to-add-single-quote-to-a-macro-variable-outside-macro/m-p/822851#M324918</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/271849"&gt;@Aniruddhaanu&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Actually I want in mail that ,this is data of May"22.&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Do it in the data step that writes the mail:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
picture mydate
  low-high = '%b"%0y' (datatype=date)
;
run;

data _null_;
var = put(intnx('month',today(),-2,'B'),mydate.);
put "This is data of " var;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This way you avoid that the quote will ever appear in the &lt;EM&gt;code&lt;/EM&gt; instead of just in data.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jul 2022 14:18:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Re-How-to-add-single-quote-to-a-macro-variable-outside-macro/m-p/822851#M324918</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-07-12T14:18:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to add single quote to a macro variable outside macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Re-How-to-add-single-quote-to-a-macro-variable-outside-macro/m-p/822861#M324922</link>
      <description>Getting ,error:open code statement recursion detected</description>
      <pubDate>Tue, 12 Jul 2022 14:30:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Re-How-to-add-single-quote-to-a-macro-variable-outside-macro/m-p/822861#M324922</guid>
      <dc:creator>Aniruddhaanu</dc:creator>
      <dc:date>2022-07-12T14:30:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to add single quote to a macro variable outside macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Re-How-to-add-single-quote-to-a-macro-variable-outside-macro/m-p/822866#M324924</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/271849"&gt;@Aniruddhaanu&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Actually I want in mail that ,this is data of May"22.&lt;BR /&gt;&lt;BR /&gt;I have checked no syntax error there.&lt;BR /&gt;Even i can Abe to create May_22 variable but unable to create May"22&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Your code, plus a RUN; statement&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data _null_
Call symput ('Month',put(intnx('month',today(),-2,'B'),monname.));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;LOG&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;1036  Data _null_
1037  Call symput ('Month',put(intnx('month',today(),-2,'B'),monname.));
                   -------                                  -
                   22                                       22
                                                            200
ERROR 22-7: Invalid option name 'Month'.

ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, /, ;, _DATA_, _LAST_, _NULL_.

ERROR 200-322: The symbol is not recognized and will be ignored.

1037! Call symput ('Month',put(intnx('month',today(),-2,'B'),monname.));
                                                    -
                                                    22
ERROR 22-7: Invalid option name ,.

1038  run;

NOTE: Compression was disabled for data set WORK.CALL because compression overhead would increase the size of the data set.
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.CALL may be incomplete.  When this step was stopped there were 0 observations and 0 variables.
WARNING: Data set WORK.CALL was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
      real time           0.02 seconds
      cpu time            0.01 seconds
&lt;/PRE&gt;
&lt;P&gt;Please provide code without syntax errors from now on.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jul 2022 14:45:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Re-How-to-add-single-quote-to-a-macro-variable-outside-macro/m-p/822866#M324924</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-07-12T14:45:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to add single quote to a macro variable outside macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Re-How-to-add-single-quote-to-a-macro-variable-outside-macro/m-p/822964#M324961</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/271849"&gt;@Aniruddhaanu&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Getting ,error:open code statement recursion detected&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;My code does not have a single element which could cause this message, it is tested. Start a new session and run my code, nothing else.&lt;/P&gt;
&lt;P&gt;If you run additional code, post your complete log.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jul 2022 18:40:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Re-How-to-add-single-quote-to-a-macro-variable-outside-macro/m-p/822964#M324961</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-07-12T18:40:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to add single quote to a macro variable outside macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Re-How-to-add-single-quote-to-a-macro-variable-outside-macro/m-p/823083#M325010</link>
      <description>&lt;P&gt;You have already got the desired result. Just add %nrbquote() to mask the single quote.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Data _null_;
Call symput ('Month1',put(intnx('month',today(),-2,'B'),monname.));
stop;
run;
%put %nrbquote( &amp;amp;month1. '22 ) ;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Jul 2022 12:17:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Re-How-to-add-single-quote-to-a-macro-variable-outside-macro/m-p/823083#M325010</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-07-13T12:17:47Z</dc:date>
    </item>
  </channel>
</rss>

