<?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: Defining a macro and then using it in a Proc export statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Defining-a-macro-and-then-using-it-in-a-Proc-export-statement/m-p/520808#M141258</link>
    <description>&lt;P&gt;Worked perfectly Kurt, thanks for your help&lt;/P&gt;&lt;P&gt;Andy&lt;/P&gt;</description>
    <pubDate>Wed, 12 Dec 2018 13:45:10 GMT</pubDate>
    <dc:creator>AJChamberlain</dc:creator>
    <dc:date>2018-12-12T13:45:10Z</dc:date>
    <item>
      <title>Defining a macro and then using it in a Proc export statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Defining-a-macro-and-then-using-it-in-a-Proc-export-statement/m-p/520774#M141248</link>
      <description>&lt;P&gt;Hi all&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to define a macro and then combine it with a Proc Edit statement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a macro which in this example is called 'Filepath' which defines the file path where I want to export my file, and I want to use data from a dataset called 'mydata' to create an excel spreadsheet in the directory specified by the macro,&amp;nbsp;the spreadsheet needs to be called 'Compare_RL'.&amp;nbsp;My code looks something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let&amp;nbsp;Filepath = \\My path name\folder;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc export data= mydata&lt;BR /&gt;outfile= "&amp;amp;Filepath.\Compare_RL.xlsx"&lt;BR /&gt;dbms=xlsx replace;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am getting an error which tells me SAS is expecting an arithmetic&amp;nbsp;operator.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas how to fix this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;A&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Dec 2018 12:26:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Defining-a-macro-and-then-using-it-in-a-Proc-export-statement/m-p/520774#M141248</guid>
      <dc:creator>AJChamberlain</dc:creator>
      <dc:date>2018-12-12T12:26:38Z</dc:date>
    </item>
    <item>
      <title>Re: Defining a macro and then using it in a Proc export statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Defining-a-macro-and-then-using-it-in-a-Proc-export-statement/m-p/520779#M141249</link>
      <description>&lt;P&gt;Please post the whole log, using the {i} button. From the %let to the run; of the proc export, including all NOTEs, ERRORs and WARNINGs up to the beginning of the next step (if there was one).&lt;/P&gt;</description>
      <pubDate>Wed, 12 Dec 2018 12:33:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Defining-a-macro-and-then-using-it-in-a-Proc-export-statement/m-p/520779#M141249</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-12-12T12:33:13Z</dc:date>
    </item>
    <item>
      <title>Re: Defining a macro and then using it in a Proc export statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Defining-a-macro-and-then-using-it-in-a-Proc-export-statement/m-p/520789#M141250</link>
      <description>&lt;P&gt;Sure&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here it is with my original macro and code from the log&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thx&lt;/P&gt;&lt;P&gt;A&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Dec 2018 13:04:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Defining-a-macro-and-then-using-it-in-a-Proc-export-statement/m-p/520789#M141250</guid>
      <dc:creator>AJChamberlain</dc:creator>
      <dc:date>2018-12-12T13:04:28Z</dc:date>
    </item>
    <item>
      <title>Re: Defining a macro and then using it in a Proc export statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Defining-a-macro-and-then-using-it-in-a-Proc-export-statement/m-p/520793#M141251</link>
      <description>&lt;P&gt;do your - need to be =&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Dec 2018 13:13:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Defining-a-macro-and-then-using-it-in-a-Proc-export-statement/m-p/520793#M141251</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2018-12-12T13:13:04Z</dc:date>
    </item>
    <item>
      <title>Re: Defining a macro and then using it in a Proc export statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Defining-a-macro-and-then-using-it-in-a-Proc-export-statement/m-p/520795#M141253</link>
      <description>&lt;P&gt;Hi VDD&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am not sure what you mean by 'do your - need to be =' my code doesn't have dashes in it. Have I misinterpreted what you meant here?&lt;/P&gt;&lt;P&gt;Thx&lt;/P&gt;&lt;P&gt;A&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Dec 2018 13:18:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Defining-a-macro-and-then-using-it-in-a-Proc-export-statement/m-p/520795#M141253</guid>
      <dc:creator>AJChamberlain</dc:creator>
      <dc:date>2018-12-12T13:18:30Z</dc:date>
    </item>
    <item>
      <title>Re: Defining a macro and then using it in a Proc export statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Defining-a-macro-and-then-using-it-in-a-Proc-export-statement/m-p/520801#M141256</link>
      <description>&lt;P&gt;Your problem is caused by improper usage of double quotes which causes a string to end prematurely and places the following text in the code instead of in the string.&lt;/P&gt;
&lt;P&gt;Use this assignment instead:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;string=compbl(cats("
  proc export
    data=final(where=(Version='", Version, "'))
    outfile= '&amp;amp;Comp_RL.\Compare_RL.xlsx'
    dbms=xlsx replace;
  sheet='", Version, "';
  run;
"));
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Since the outermost quotes are double, all macro references inside will be resolved, the single quotes are just part of the string. Only when the result is put into the execution queue by call execute() will the single quotes have meaning, but then the macro variables have already been replaced by their content.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Dec 2018 13:27:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Defining-a-macro-and-then-using-it-in-a-Proc-export-statement/m-p/520801#M141256</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-12-12T13:27:47Z</dc:date>
    </item>
    <item>
      <title>Re: Defining a macro and then using it in a Proc export statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Defining-a-macro-and-then-using-it-in-a-Proc-export-statement/m-p/520808#M141258</link>
      <description>&lt;P&gt;Worked perfectly Kurt, thanks for your help&lt;/P&gt;&lt;P&gt;Andy&lt;/P&gt;</description>
      <pubDate>Wed, 12 Dec 2018 13:45:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Defining-a-macro-and-then-using-it-in-a-Proc-export-statement/m-p/520808#M141258</guid>
      <dc:creator>AJChamberlain</dc:creator>
      <dc:date>2018-12-12T13:45:10Z</dc:date>
    </item>
    <item>
      <title>Re: Defining a macro and then using it in a Proc export statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Defining-a-macro-and-then-using-it-in-a-Proc-export-statement/m-p/520888#M141282</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/250288"&gt;@AJChamberlain&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Sure&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here it is with my original macro and code from the log&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;thx&lt;/P&gt;
&lt;P&gt;A&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;For future reference please post code and log into a code box opened using the forum's {I} icon. Just copy from the editor or log and paste.&lt;/P&gt;
&lt;P&gt;Placing such into a word processor file format (docx) has resulted in code changing such as programming quotes from " to curly quotes and other sometimes invisible characters getting inserted that will prevent the code from running properly as well as forcing word wrap that may make some of the diagnostics in the error messages harder to interpret. The code box does not do any reformatting.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Dec 2018 16:22:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Defining-a-macro-and-then-using-it-in-a-Proc-export-statement/m-p/520888#M141282</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-12-12T16:22:05Z</dc:date>
    </item>
  </channel>
</rss>

