<?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 Getting a macro variable to resolve within an x command in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Getting-a-macro-variable-to-resolve-within-an-x-command/m-p/78057#M16922</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;using an X command to copy a file:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;x 'copy &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "C:\temp\sample.xls"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "C:\temp\sample2.xls"';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But now I'd like sample2 to be a macro variable, but it won't resolve inside the single quotes (I'm assuming). How would I go about getting this to work? I'm on SAS 9.2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let my_var=test;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;x 'copy &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "C:\temp\sample.xls"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "C:\temp\&amp;amp;test..xls"';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 17 Jan 2013 17:56:24 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2013-01-17T17:56:24Z</dc:date>
    <item>
      <title>Getting a macro variable to resolve within an x command</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-a-macro-variable-to-resolve-within-an-x-command/m-p/78057#M16922</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;using an X command to copy a file:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;x 'copy &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "C:\temp\sample.xls"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "C:\temp\sample2.xls"';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But now I'd like sample2 to be a macro variable, but it won't resolve inside the single quotes (I'm assuming). How would I go about getting this to work? I'm on SAS 9.2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let my_var=test;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;x 'copy &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "C:\temp\sample.xls"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "C:\temp\&amp;amp;test..xls"';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Jan 2013 17:56:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-a-macro-variable-to-resolve-within-an-x-command/m-p/78057#M16922</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2013-01-17T17:56:24Z</dc:date>
    </item>
    <item>
      <title>Re: Getting a macro variable to resolve within an x command</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-a-macro-variable-to-resolve-within-an-x-command/m-p/78058#M16923</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Reeza,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The entire string after X is in single quotes ... and I know that you know that macro variables don't resolve within single quotes.&amp;nbsp; Reverse them:&amp;nbsp; double quotes on the outside and single quotes on the inside.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Alternatively, you could replace X with %SYSEXEC and you wouldn't need the outer quotes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Jan 2013 18:04:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-a-macro-variable-to-resolve-within-an-x-command/m-p/78058#M16923</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2013-01-17T18:04:53Z</dc:date>
    </item>
    <item>
      <title>Re: Getting a macro variable to resolve within an x command</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-a-macro-variable-to-resolve-within-an-x-command/m-p/78059#M16924</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I tried reversing the quotes and it doesn't work .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%sysexec works perfectly, Thanks Astounding&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%sysexec copy "file1.xls" "&amp;amp;file_name..xls";&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Reeza&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Jan 2013 18:10:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-a-macro-variable-to-resolve-within-an-x-command/m-p/78059#M16924</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2013-01-17T18:10:19Z</dc:date>
    </item>
    <item>
      <title>Re: Getting a macro variable to resolve within an x command</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-a-macro-variable-to-resolve-within-an-x-command/m-p/78060#M16925</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;To allow you to specify filenames with embedded spaces DOS wants you to enclose your filenames in dquotes.&lt;/P&gt;&lt;P&gt;To allow your macro variables to expand SAS wants you to enclose the full command in dquotes.&lt;/P&gt;&lt;P&gt;I have found that the QUOTE function helps with this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%let my_var=My Goofy Filename;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;x %sysfunc(quote(copy "C:\temp\sample.xls" "C:\temp\&amp;amp;test..xls")) ;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Jan 2013 18:16:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-a-macro-variable-to-resolve-within-an-x-command/m-p/78060#M16925</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-01-17T18:16:38Z</dc:date>
    </item>
    <item>
      <title>Re: Getting a macro variable to resolve within an x command</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-a-macro-variable-to-resolve-within-an-x-command/m-p/78061#M16926</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Reeza&lt;/P&gt;&lt;P&gt;I have a very little to add but it seems a bit significant..&lt;/P&gt;&lt;P&gt;Although Tom has provided a most reliable way of ensuring a string is properly quoted even if you are unsure of what it contains (by using the quote() function) there is a simpler way that is also very generalised - when seeking to deliver quote marks within a string that is quoted(with the same kind of quotes) repeat the embedded quote - for example&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;x "copy &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ""C:\temp\sample.xls""&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ""C:\temp\&amp;amp;test..xls"" ";&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 20 Jan 2013 18:51:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-a-macro-variable-to-resolve-within-an-x-command/m-p/78061#M16926</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2013-01-20T18:51:28Z</dc:date>
    </item>
    <item>
      <title>Re: Getting a macro variable to resolve within an x command</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-a-macro-variable-to-resolve-within-an-x-command/m-p/78062#M16927</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I had tried that as well Peter, but it didn't work on the system I was on. I'll retry again tomorrow to verify.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Jan 2013 00:03:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-a-macro-variable-to-resolve-within-an-x-command/m-p/78062#M16927</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2013-01-21T00:03:55Z</dc:date>
    </item>
    <item>
      <title>Re: Getting a macro variable to resolve within an x command</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-a-macro-variable-to-resolve-within-an-x-command/m-p/366817#M87280</link>
      <description>&lt;P&gt;I tried to used the same command by extending in a do loop. But it did &amp;nbsp;not work as expected. &amp;nbsp;&lt;/P&gt;&lt;P&gt;OPTIONS NOXWAIT NOXSYNC;&lt;BR /&gt;%macro zxc;&lt;BR /&gt;%do i= 1 %to 68;&lt;BR /&gt;%SYSEXEC copy "D:\temp\&amp;amp;&amp;amp;memname&amp;amp;i." "c:\temp\&amp;amp;&amp;amp;memname&amp;amp;i.";&lt;BR /&gt;%end;&lt;BR /&gt;%mend zxc;&lt;BR /&gt;%zxc;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In The macro arrray&amp;nbsp;&lt;SPAN&gt;&amp;amp;&amp;amp;memname&amp;amp;i, only the counter "i" is getting resolved.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;SYMBOLGEN: Macro variable I resolves to&amp;nbsp;1&lt;BR /&gt;SYMBOLGEN: Macro variable I resolves to&amp;nbsp;1&lt;BR /&gt;SYMBOLGEN: Macro variable I resolves to&amp;nbsp;2&lt;BR /&gt;SYMBOLGEN: Macro variable I resolves to&amp;nbsp;2&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jun 2017 02:01:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-a-macro-variable-to-resolve-within-an-x-command/m-p/366817#M87280</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2017-06-14T02:01:45Z</dc:date>
    </item>
  </channel>
</rss>

