<?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: X Windows Command - Cd to a folder directory with &amp;quot;&amp;&amp;quot; in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/X-Windows-Command-Cd-to-a-folder-directory-with-quot-quot/m-p/22682#M3684</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your path is &lt;EM&gt;not&lt;/EM&gt; to be resolved by an explicit or implicit &lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 10pt;"&gt;%eval&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;()&lt;/SPAN&gt;. Thus you don't need to macro quote the singleton ampersand character at all. The ampersand has to be hidden from the cmd.exe shell though, since it is a command separator to the interpreter (see &lt;A href="http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/ntcmds_shelloverview.mspx?mfr=true"&gt;msdn article&lt;/A&gt;). The following worked fine on my sas running on a windows 7:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 10pt;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt; drive = c:;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 10pt;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt; path = /temp/a &amp;amp; b;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 10pt;"&gt;x&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #800080; font-family: Courier New; font-size: 10pt;"&gt;"&amp;amp;drive &amp;amp; cd ""&amp;amp;path"" &amp;amp; dir *.csv &amp;gt; list.txt"&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 03 Jan 2012 18:14:33 GMT</pubDate>
    <dc:creator>chang_y_chung_hotmail_com</dc:creator>
    <dc:date>2012-01-03T18:14:33Z</dc:date>
    <item>
      <title>X Windows Command - Cd to a folder directory with "&amp;"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/X-Windows-Command-Cd-to-a-folder-directory-with-quot-quot/m-p/22679#M3681</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a quick SAS question regarding the “x” command. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to access the following directory with cmd to createa list of csv files in a particular folder.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: blue; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;Drive=M:;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: blue; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;Path=&lt;/SPAN&gt;&lt;SPAN style="color: blue; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;%nrstr&lt;/SPAN&gt;&lt;SPAN style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;(Clients\Reporting\01Data\A &amp;amp; B\Extracts);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;x &lt;/SPAN&gt;&lt;SPAN style="color: purple; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;"&amp;amp;drive."&lt;/SPAN&gt;&lt;SPAN style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;x &lt;/SPAN&gt;&lt;SPAN style="color: purple; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;"cd&amp;amp;path."&lt;/SPAN&gt;&lt;SPAN style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;x &lt;/SPAN&gt;&lt;SPAN style="color: purple; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;"dir *.csv &amp;gt;xlsFileList.txt"&lt;/SPAN&gt;&lt;SPAN style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;Unfortunately, this failed because of the “&amp;amp;”sign in the directory. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Testing with cmd directly, I found that entering the following command works: cd &lt;SPAN style="color: #000000; font-family: 'Courier New'; background-color: #ffffff;"&gt;Clients\Reporting\01Data\&lt;SPAN style="font-family: 'arial black', 'avant garde';"&gt;&lt;STRONG&gt;"A &amp;amp; B"&lt;/STRONG&gt;&lt;/SPAN&gt;\Extracts&lt;/SPAN&gt;&lt;SPAN style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;Logically we followed this by running the SAScommand&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;x &lt;/SPAN&gt;&lt;SPAN style="color: purple; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;‘&lt;/SPAN&gt;&lt;SPAN style="color: purple; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;cd Clients\Reporting\01 Data\”A &amp;amp; B”\Extracts.’&lt;/SPAN&gt;&lt;SPAN style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;Once again, this failed. I have been stuck on this for the past hour. It would be much appreciated if someone could provide a solution.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Jan 2012 05:00:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/X-Windows-Command-Cd-to-a-folder-directory-with-quot-quot/m-p/22679#M3681</guid>
      <dc:creator>danielh</dc:creator>
      <dc:date>2012-01-03T05:00:04Z</dc:date>
    </item>
    <item>
      <title>X Windows Command - Cd to a folder directory with "&amp;"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/X-Windows-Command-Cd-to-a-folder-directory-with-quot-quot/m-p/22680#M3682</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I believe this is only about correct quoting. Below code worked for me:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;options noxwait;&lt;BR /&gt;%let path=%nrbquote(C:\temp\"this &amp;amp; that");&lt;BR /&gt;data _null_;&lt;BR /&gt;&amp;nbsp; x "mkdir &amp;amp;path";&lt;BR /&gt;&amp;nbsp; x "dir &amp;gt; &amp;amp;path\dirlist.txt";&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;DIV class="mcePaste" id="_mcePaste" style="position: absolute; width: 1px; height: 1px; overflow: hidden; top: 0px; left: -10000px;"&gt;﻿&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Jan 2012 05:22:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/X-Windows-Command-Cd-to-a-folder-directory-with-quot-quot/m-p/22680#M3682</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2012-01-03T05:22:40Z</dc:date>
    </item>
    <item>
      <title>Re: X Windows Command - Cd to a folder directory with "&amp;"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/X-Windows-Command-Cd-to-a-folder-directory-with-quot-quot/m-p/22681#M3683</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Use double quote characters as your outside quotes and SAS will expand the macro variable references.&lt;/P&gt;&lt;P&gt;Use the QUOTE function to handle doubling the embedded quotes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let Drive=M:;&lt;/P&gt;&lt;P&gt;%let Path=%nrstr(Clients\Reporting\01Data\A &amp;amp; B\Extracts);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;x %sysfunc(quote(dir "&amp;amp;drive\&amp;amp;path" &amp;gt;xlsFileList.txt));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Simplified command.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Jan 2012 15:27:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/X-Windows-Command-Cd-to-a-folder-directory-with-quot-quot/m-p/22681#M3683</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-01-03T15:27:16Z</dc:date>
    </item>
    <item>
      <title>Re: X Windows Command - Cd to a folder directory with "&amp;"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/X-Windows-Command-Cd-to-a-folder-directory-with-quot-quot/m-p/22682#M3684</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your path is &lt;EM&gt;not&lt;/EM&gt; to be resolved by an explicit or implicit &lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 10pt;"&gt;%eval&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;()&lt;/SPAN&gt;. Thus you don't need to macro quote the singleton ampersand character at all. The ampersand has to be hidden from the cmd.exe shell though, since it is a command separator to the interpreter (see &lt;A href="http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/ntcmds_shelloverview.mspx?mfr=true"&gt;msdn article&lt;/A&gt;). The following worked fine on my sas running on a windows 7:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 10pt;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt; drive = c:;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 10pt;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt; path = /temp/a &amp;amp; b;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 10pt;"&gt;x&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #800080; font-family: Courier New; font-size: 10pt;"&gt;"&amp;amp;drive &amp;amp; cd ""&amp;amp;path"" &amp;amp; dir *.csv &amp;gt; list.txt"&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Jan 2012 18:14:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/X-Windows-Command-Cd-to-a-folder-directory-with-quot-quot/m-p/22682#M3684</guid>
      <dc:creator>chang_y_chung_hotmail_com</dc:creator>
      <dc:date>2012-01-03T18:14:33Z</dc:date>
    </item>
    <item>
      <title>Re: X Windows Command - Cd to a folder directory with "&amp;"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/X-Windows-Command-Cd-to-a-folder-directory-with-quot-quot/m-p/22683#M3685</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Another way is to make a .bat file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;%let Drive=c: ;
%let Path=\temp\A &amp;amp; B\Extracts ;

data _null_;
 file 'c:\x.bat';
 a='cd "'||"&amp;amp;drive&amp;amp;path"||'"';
 put a;
 b='dir *.pdf &amp;gt; x.txt';
 put b;
run;
options noxwait;
x 'c:\x.bat';
x 'del c:\x.bat';
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Jan 2012 02:36:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/X-Windows-Command-Cd-to-a-folder-directory-with-quot-quot/m-p/22683#M3685</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2012-01-04T02:36:11Z</dc:date>
    </item>
  </channel>
</rss>

