<?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: Using double quotation marks in a macro variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Using-double-quotation-marks-in-a-macro-variable/m-p/210098#M38943</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Astounding.&lt;/P&gt;&lt;P&gt;data_null_;'s suggestion worked just fine.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;FarmName = %sysfunc(quote(%superq(farmname))&lt;STRONG&gt;)&lt;/STRONG&gt;; (Needed one more ")" &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 06 May 2015 13:29:31 GMT</pubDate>
    <dc:creator>MichaelvanStraten</dc:creator>
    <dc:date>2015-05-06T13:29:31Z</dc:date>
    <item>
      <title>Using double quotation marks in a macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-double-quotation-marks-in-a-macro-variable/m-p/210088#M38933</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please forgive me if I use any incorrect terminology, most of my knowledge in SAS programing is a result of self study.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a string variable in a data set. The values of this variable are names and some of them include a single double quotation mark, e.g. &lt;STRONG&gt;farm a"bc&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to assign these values to a macro variable I call &lt;STRONG&gt;farmname &lt;/STRONG&gt;using the following line (within a data step):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;farmname = "&amp;amp;farmname";&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This data step is embedded in a macro that works iteratively.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem is, the double quotation mark (DQM) in the variable name is recognized as a closing DQM, and the macro stops running and reports it has encountered a very long string. I have changed the DQM in the names to single quotation marks (e.g. &lt;STRONG&gt;farm a'bc&lt;/STRONG&gt;) and everything runs perfectly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My question is this: is it possible to leave a single DQM in the names, and still use them as a macro variables?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Michael&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 May 2015 09:02:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-double-quotation-marks-in-a-macro-variable/m-p/210088#M38933</guid>
      <dc:creator>MichaelvanStraten</dc:creator>
      <dc:date>2015-05-06T09:02:24Z</dc:date>
    </item>
    <item>
      <title>Re: Using double quotation marks in a macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-double-quotation-marks-in-a-macro-variable/m-p/210089#M38934</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Since single quotes around strings prevent the substitution of macro variables, I think you will be safe.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 May 2015 09:10:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-double-quotation-marks-in-a-macro-variable/m-p/210089#M38934</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2015-05-06T09:10:30Z</dc:date>
    </item>
    <item>
      <title>Re: Using double quotation marks in a macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-double-quotation-marks-in-a-macro-variable/m-p/210090#M38935</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your fast reply. If you mean:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;farmname='&amp;amp;farmname';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried this and the macro names don't resolve.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 May 2015 09:17:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-double-quotation-marks-in-a-macro-variable/m-p/210090#M38935</guid>
      <dc:creator>MichaelvanStraten</dc:creator>
      <dc:date>2015-05-06T09:17:26Z</dc:date>
    </item>
    <item>
      <title>Re: Using double quotation marks in a macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-double-quotation-marks-in-a-macro-variable/m-p/210091#M38936</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm confused by your question (but still, the answer is yes : )&lt;/P&gt;&lt;P&gt;The statement:&lt;/P&gt;&lt;P&gt;farmname="&amp;amp;farmname";&lt;/P&gt;&lt;P&gt;does not assign a values to a macro variable.&amp;nbsp; It assigns a value to a data step variable (after resolving &amp;amp;farmname).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To get the solo double-quote into a macro variable, you could use something like:&lt;/P&gt;&lt;PRE&gt;%let x=farm%str(%")abc;

data _null_;
&amp;nbsp; call symputx("y",'farm"abc');
&amp;nbsp; call symputx("z","farm""abc");
run;

&lt;/PRE&gt;&lt;P&gt;To use the macro variable in a datastep assignment statement you could use:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;data want;
&amp;nbsp; farmname1="&amp;amp;x";
&amp;nbsp; farmname2="%superq(y)";
&amp;nbsp; farmname3="%superq(z)";
run;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Luckily for you, Art Carpenter has a paper just on quote marks, highly recommended reading:&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/resources/papers/proceedings15/2221-2015.pdf"&gt;http://support.sas.com/resources/papers/proceedings15/2221-2015.pdf&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 May 2015 09:56:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-double-quotation-marks-in-a-macro-variable/m-p/210091#M38936</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2015-05-06T09:56:55Z</dc:date>
    </item>
    <item>
      <title>Re: Using double quotation marks in a macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-double-quotation-marks-in-a-macro-variable/m-p/210092#M38937</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What I meant is that, if you can substitute single quotation marks for doubles in your data (and macro vars), you can then safely use them inside double quotation marks when resolving the macrovars. As long as you use double quotation marks, the macrovar itself can contain any number of SQMs without conflicts.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 May 2015 10:16:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-double-quotation-marks-in-a-macro-variable/m-p/210092#M38937</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2015-05-06T10:16:26Z</dc:date>
    </item>
    <item>
      <title>Re: Using double quotation marks in a macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-double-quotation-marks-in-a-macro-variable/m-p/210093#M38938</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry for confusing you.. and thanks for the answer.&lt;/P&gt;&lt;P&gt;Indeed, I assigned the values to a macro variable using:&lt;/P&gt;&lt;P&gt;call symput ('farm',trim(farm)); in a separate data step.&lt;/P&gt;&lt;P&gt;Then I assigned a value to a data step variable with:&lt;/P&gt;&lt;P&gt;farmname="&amp;amp;farmname";&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have to digest your answer to understand it. Will it work if the names have different structures? E.g. one name includes double quote marks yet another does not? String length also varies.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, thanks for the link.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 May 2015 10:22:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-double-quotation-marks-in-a-macro-variable/m-p/210093#M38938</guid>
      <dc:creator>MichaelvanStraten</dc:creator>
      <dc:date>2015-05-06T10:22:56Z</dc:date>
    </item>
    <item>
      <title>Re: Using double quotation marks in a macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-double-quotation-marks-in-a-macro-variable/m-p/210094#M38939</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you, but yes, I know that and it worked. Problem is input data will always contain DQM and I want to avoid the need to constantly change them to SQM.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 May 2015 10:25:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-double-quotation-marks-in-a-macro-variable/m-p/210094#M38939</guid>
      <dc:creator>MichaelvanStraten</dc:creator>
      <dc:date>2015-05-06T10:25:11Z</dc:date>
    </item>
    <item>
      <title>Re: Using double quotation marks in a macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-double-quotation-marks-in-a-macro-variable/m-p/210095#M38940</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Use the QUOTE function and let SAS figure it out.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Change&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;farmname = "&amp;amp;farmname";&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;To:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;FarmName = %sysfunc(quote(%superq(farmname)));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;Note: The argument of SUPERQ is macro name not the resolved value.&amp;nbsp; In other words NO ampersand.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;Better:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Retain FarmName &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt; %sysfunc(quote(%superq(farmname)));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;Another way to avoid the unmatched quote issue is to use SYMGET but you want to be careful you don't execute SYMGET unnecessarily.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;length FarmName $16;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;retain farmname;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;if _n_ eq 1 then symget('farmname');&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 May 2015 10:44:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-double-quotation-marks-in-a-macro-variable/m-p/210095#M38940</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2015-05-06T10:44:51Z</dc:date>
    </item>
    <item>
      <title>Re: Using double quotation marks in a macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-double-quotation-marks-in-a-macro-variable/m-p/210096#M38941</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks a lot data_null_; I'll digest, then try.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 May 2015 10:55:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-double-quotation-marks-in-a-macro-variable/m-p/210096#M38941</guid>
      <dc:creator>MichaelvanStraten</dc:creator>
      <dc:date>2015-05-06T10:55:28Z</dc:date>
    </item>
    <item>
      <title>Re: Using double quotation marks in a macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-double-quotation-marks-in-a-macro-variable/m-p/210097#M38942</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Perhaps this combination would be easier.&amp;nbsp; In a DATA step:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;length farmname $ 50;&lt;/P&gt;&lt;P&gt;farmname = symget('farmname');&lt;/P&gt;&lt;P&gt;If you omit the LENGTH statement, FARMNAME would receive a length of $200 but the code would still work.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 May 2015 13:08:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-double-quotation-marks-in-a-macro-variable/m-p/210097#M38942</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2015-05-06T13:08:36Z</dc:date>
    </item>
    <item>
      <title>Re: Using double quotation marks in a macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-double-quotation-marks-in-a-macro-variable/m-p/210098#M38943</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Astounding.&lt;/P&gt;&lt;P&gt;data_null_;'s suggestion worked just fine.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;FarmName = %sysfunc(quote(%superq(farmname))&lt;STRONG&gt;)&lt;/STRONG&gt;; (Needed one more ")" &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 May 2015 13:29:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-double-quotation-marks-in-a-macro-variable/m-p/210098#M38943</guid>
      <dc:creator>MichaelvanStraten</dc:creator>
      <dc:date>2015-05-06T13:29:31Z</dc:date>
    </item>
  </channel>
</rss>

