<?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: Concatenation of Quotes and Strings in Macros in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Concatenation-of-Quotes-and-Strings-in-Macros/m-p/681206#M206029</link>
    <description>&lt;P&gt;It might be easier if you build the string in a data step rather than with macro language, such as:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
outfile = '''C:\Datasets\R&amp;amp;R\Output\' || "&amp;amp;dataset'";
call symputx('outfile', outfile);&lt;BR /&gt;run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The macro variable &amp;amp;OUTFILE should be useful in your existing PROC EXPORT.&lt;/P&gt;</description>
    <pubDate>Thu, 03 Sep 2020 03:01:36 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2020-09-03T03:01:36Z</dc:date>
    <item>
      <title>Concatenation of Quotes and Strings in Macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenation-of-Quotes-and-Strings-in-Macros/m-p/680833#M205856</link>
      <description>&lt;P&gt;I am attempting to use PROC EXPORT to output many Excel workbooks with the following code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let dataset = time_off;
proc export
	data=&amp;amp;dataset
	dbms=xlsx
	outfile="C:\Datasets\R&amp;amp;R\Output\&amp;amp;dataset"
	replace;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Unfortunately, it is necessary for the OUTFILE path to contain an ampersand which generates a warning upon execution.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;WARNING: Apparent symbolic reference R not resolved.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I am trying to get around this by building the path using macros to combine quotes and strings.&amp;nbsp; For example:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let dataset = time_off;
%let path = C:\Datasets\R&amp;amp;R\Output\&amp;amp;dataset;
proc export
	data=&amp;amp;dataset
	dbms=xlsx
	outfile=&amp;amp;path
	replace;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This generates the following error because, I assume, quotes are missing from the value for OUTFILE.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;24         %let dataset = time_off;
25         %let path = C:\Datasets\R&amp;amp;R\Output\&amp;amp;dataset;
WARNING: Apparent symbolic reference R not resolved.
26         proc export
27         	data=&amp;amp;dataset
28         	dbms=xlsx
NOTE: PROCEDURE EXPORT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      
WARNING: Apparent symbolic reference R not resolved.
NOTE: The SAS System stopped processing this step because of errors.
29         	outfile=&amp;amp;path
30         	replace;
NOTE: Line generated by the macro variable "PATH".
30         C:\Datasets\R&amp;amp;R\Output\time_off
            _
            22
            76
ERROR 22-322: Syntax error, expecting one of the following: ;, DATA, DBLABEL, DBMS, DEBUG, FILE, LABEL, OUTFILE, OUTTABLE, REPLACE, 
              TABLE, _DEBUG_.  

ERROR 76-322: Syntax error, statement will be ignored.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Therefore, I am trying to programmatically build a string using macros and concatenation with the code shown below.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let dataset = time_off;
%let path = %sysfunc(cat("'",C:\Datasets\R&amp;amp;R\Output\,&amp;amp;dataset,"'"))&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This, however, produces these errors:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;24         %let dataset = time_off;
25         %let path = %sysfunc(cat("'",C:\Datasets\R&amp;amp;R\Output\,&amp;amp;dataset,"'"));
WARNING: Apparent symbolic reference R not resolved.
WARNING: Apparent symbolic reference R not resolved.
NOTE: Line generated by the macro function "SYSFUNC".
25          "'"C:\Datasets\R&amp;amp;R\Output\time_off"'"
            ___
            49
WARNING: Apparent symbolic reference R not resolved.

NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release.  Inserting white space 
             between a quoted string and the succeeding identifier is recommended.


26         proc export
27         	data=&amp;amp;dataset
28         	dbms=xlsx
NOTE: PROCEDURE EXPORT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      
WARNING: Apparent symbolic reference R not resolved.
NOTE: The SAS System stopped processing this step because of errors.
29         	outfile=&amp;amp;path
30         	replace;
NOTE: Line generated by the macro variable "PATH".
30         "'"C:\Datasets\R&amp;amp;R\Output\time_off"'"
           ___
           49
              _
              22
              76
NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release.  Inserting white space 
             between a quoted string and the succeeding identifier is recommended.
2                                                          The SAS System


ERROR 22-322: Syntax error, expecting one of the following: ;, DATA, DBLABEL, DBMS, DEBUG, FILE, LABEL, OUTFILE, OUTTABLE, REPLACE, 
              TABLE, _DEBUG_.  

ERROR 76-322: Syntax error, statement will be ignored.

31         run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Ultimately what I am trying to do is build the following string as the argument for OUTFILE:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;'C:\Datasets\R&amp;amp;R\Output\time_off'&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I would appreciate any assistance that could be provided.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Sep 2020 23:10:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenation-of-Quotes-and-Strings-in-Macros/m-p/680833#M205856</guid>
      <dc:creator>Actuary</dc:creator>
      <dc:date>2020-09-01T23:10:13Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenation of Quotes and Strings in Macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenation-of-Quotes-and-Strings-in-Macros/m-p/680837#M205857</link>
      <description>&lt;P&gt;You want to use the %nrstr() function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/?docsetId=mcrolref&amp;amp;docsetTarget=p0pnc7p9n4h6g5n16g6js048nhfl.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en"&gt;https://documentation.sas.com/?docsetId=mcrolref&amp;amp;docsetTarget=p0pnc7p9n4h6g5n16g6js048nhfl.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en&lt;/A&gt; (scroll down) &lt;/P&gt;
&lt;DIV id="tap-translate"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Tue, 01 Sep 2020 23:40:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenation-of-Quotes-and-Strings-in-Macros/m-p/680837#M205857</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-09-01T23:40:16Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenation of Quotes and Strings in Macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenation-of-Quotes-and-Strings-in-Macros/m-p/680866#M205877</link>
      <description>&lt;P&gt;This "problem" only exists, because you are using special chars in a directory name, so the solution is quite simple: don't do that.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Sep 2020 04:56:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenation-of-Quotes-and-Strings-in-Macros/m-p/680866#M205877</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2020-09-02T04:56:57Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenation of Quotes and Strings in Macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenation-of-Quotes-and-Strings-in-Macros/m-p/681206#M206029</link>
      <description>&lt;P&gt;It might be easier if you build the string in a data step rather than with macro language, such as:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
outfile = '''C:\Datasets\R&amp;amp;R\Output\' || "&amp;amp;dataset'";
call symputx('outfile', outfile);&lt;BR /&gt;run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The macro variable &amp;amp;OUTFILE should be useful in your existing PROC EXPORT.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Sep 2020 03:01:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenation-of-Quotes-and-Strings-in-Macros/m-p/681206#M206029</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2020-09-03T03:01:36Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenation of Quotes and Strings in Macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenation-of-Quotes-and-Strings-in-Macros/m-p/681236#M206043</link>
      <description>&lt;P&gt;Don't use special symbols in directory names; the ampersand is particularly bad, because it has special meaning (not only in SAS).&lt;/P&gt;</description>
      <pubDate>Thu, 03 Sep 2020 06:45:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenation-of-Quotes-and-Strings-in-Macros/m-p/681236#M206043</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-09-03T06:45:14Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenation of Quotes and Strings in Macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenation-of-Quotes-and-Strings-in-Macros/m-p/681755#M206259</link>
      <description>&lt;P&gt;Thank you on two accounts, first for properly interpreting the problem I faced and second for providing this elegant solution.&amp;nbsp; Well done.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Sep 2020 20:53:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenation-of-Quotes-and-Strings-in-Macros/m-p/681755#M206259</guid>
      <dc:creator>Actuary</dc:creator>
      <dc:date>2020-09-04T20:53:23Z</dc:date>
    </item>
  </channel>
</rss>

