<?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 dopen to open directory name that contains spaces in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/dopen-to-open-directory-name-that-contains-spaces/m-p/130139#M26567</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am using dopen and dread to look at all of the files and directories in a particular directory structure, but dopen is failing to open directories whose names contain embedded spaces.&lt;/P&gt;&lt;P&gt;I'm running SAS 9.3 on a unix platform, and have escaped the spaces using the backslash (\) character, so a a directory named 'older mapping docs' is referred to as 'older\ mapping\ docs'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The filename function to assign a fileref to the directory gives a zero (successful) return code, but when I try to use dopen to open the directory, the DID (directory ID) returned is 0, meaning the operation failed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any suggestions for working around this problem?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 31 May 2012 14:00:55 GMT</pubDate>
    <dc:creator>Marty</dc:creator>
    <dc:date>2012-05-31T14:00:55Z</dc:date>
    <item>
      <title>dopen to open directory name that contains spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/dopen-to-open-directory-name-that-contains-spaces/m-p/130139#M26567</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am using dopen and dread to look at all of the files and directories in a particular directory structure, but dopen is failing to open directories whose names contain embedded spaces.&lt;/P&gt;&lt;P&gt;I'm running SAS 9.3 on a unix platform, and have escaped the spaces using the backslash (\) character, so a a directory named 'older mapping docs' is referred to as 'older\ mapping\ docs'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The filename function to assign a fileref to the directory gives a zero (successful) return code, but when I try to use dopen to open the directory, the DID (directory ID) returned is 0, meaning the operation failed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any suggestions for working around this problem?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 May 2012 14:00:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/dopen-to-open-directory-name-that-contains-spaces/m-p/130139#M26567</guid>
      <dc:creator>Marty</dc:creator>
      <dc:date>2012-05-31T14:00:55Z</dc:date>
    </item>
    <item>
      <title>Re: dopen to open directory name that contains spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/dopen-to-open-directory-name-that-contains-spaces/m-p/130140#M26568</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You should be able to do this without needing to escape the space.&amp;nbsp; This works correctly for me:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_ ;&lt;/P&gt;&lt;P&gt;rc=filename('mydir', "$HOME/space dir") ;&lt;/P&gt;&lt;P&gt;put rc=;&lt;/P&gt;&lt;P&gt;did=dopen('mydir') ;&lt;/P&gt;&lt;P&gt;put did=;&lt;/P&gt;&lt;P&gt;run ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOG:&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp; data _null_ ;&lt;BR /&gt;2&amp;nbsp;&amp;nbsp; rc=filename('mydir', "$HOME/space dir") ;&lt;BR /&gt;3&amp;nbsp;&amp;nbsp; put rc=;&lt;BR /&gt;4&amp;nbsp;&amp;nbsp; did=dopen('mydir') ;&lt;BR /&gt;5&amp;nbsp;&amp;nbsp; put did=;&lt;BR /&gt;6&amp;nbsp;&amp;nbsp; run ;&lt;/P&gt;&lt;P&gt;rc=0&lt;BR /&gt;did=1&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 May 2012 14:24:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/dopen-to-open-directory-name-that-contains-spaces/m-p/130140#M26568</guid>
      <dc:creator>TimB_SAS</dc:creator>
      <dc:date>2012-05-31T14:24:17Z</dc:date>
    </item>
    <item>
      <title>Re: dopen to open directory name that contains spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/dopen-to-open-directory-name-that-contains-spaces/m-p/130141#M26569</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm using %sysfunc to open and read the directories using macro code.&lt;/P&gt;&lt;P&gt;my initial code did not escape the spaces, but was not working. &lt;/P&gt;&lt;P&gt;I have just experimented with using %nrbquote to preserve the spaces in the macro variables, and that does seem to work - thanks!&lt;/P&gt;&lt;P&gt;LOG excerpt:&lt;/P&gt;&lt;P&gt;9&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let _dirpath=%nrbquote(/data/hdi/supptbls/wlp_edwardlz/0003_201105/medmgmt/older mapping docs); &lt;/P&gt;&lt;P&gt;10&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let rc=%sysfunc(filename(filrf2,%nrbquote(&amp;amp;_dirpath))); &lt;/P&gt;&lt;P&gt;11&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %put rc=&amp;amp;rc;&lt;/P&gt;&lt;P&gt;rc=0&lt;/P&gt;&lt;P&gt;12&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let _did2=%sysfunc(dopen(&amp;amp;&amp;amp;filrf2));&lt;/P&gt;&lt;P&gt;13&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %put _did2=&amp;amp;_did2;&lt;/P&gt;&lt;P&gt;_did2=2&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 May 2012 15:00:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/dopen-to-open-directory-name-that-contains-spaces/m-p/130141#M26569</guid>
      <dc:creator>Marty</dc:creator>
      <dc:date>2012-05-31T15:00:23Z</dc:date>
    </item>
    <item>
      <title>Re: dopen to open directory name that contains spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/dopen-to-open-directory-name-that-contains-spaces/m-p/130142#M26570</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think it is because you are passing the wrong parameter value into the DOPEN call because of an extra &amp;amp;.&lt;/P&gt;&lt;P&gt;The FILENAME function call will either use the filename in the macro variable FILRF2 (or if it is empty it will make up a name and set FILRF2 to the new name).&amp;nbsp; So in the call to DOPEN you should be passing the value of FILRF2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let dsid=%sysfunc(dopen(&amp;amp;FILRF2));&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 May 2012 15:25:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/dopen-to-open-directory-name-that-contains-spaces/m-p/130142#M26570</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-05-31T15:25:04Z</dc:date>
    </item>
    <item>
      <title>Re: dopen to open directory name that contains spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/dopen-to-open-directory-name-that-contains-spaces/m-p/130143#M26571</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry - that was a typo from simplifying my example. I had a double ampersand because the number at the end of the filrf variable name is being calculated, so the field reference was &amp;amp;&amp;amp;filrf&amp;amp;fnbr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The log from the corrected test code is:&lt;/P&gt;&lt;P&gt;8&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;9&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let _dirpath=%nrbquote(/data/hdi/supptbls/wlp_edwardlz/0003_201105/medmgmt/older mapping docs); &lt;/P&gt;&lt;P&gt;10&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let rc=%sysfunc(filename(filrf2,%nrbquote(&amp;amp;_dirpath))); &lt;/P&gt;&lt;P&gt;11&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %put rc=&amp;amp;rc;&lt;/P&gt;&lt;P&gt;rc=0&lt;/P&gt;&lt;P&gt;12&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let _did2=%sysfunc(dopen(&amp;amp;filrf2));&lt;/P&gt;&lt;P&gt;13&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %put _did2=&amp;amp;_did2;&lt;/P&gt;&lt;P&gt;_did2=2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is working - thanks again.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 May 2012 15:38:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/dopen-to-open-directory-name-that-contains-spaces/m-p/130143#M26571</guid>
      <dc:creator>Marty</dc:creator>
      <dc:date>2012-05-31T15:38:06Z</dc:date>
    </item>
  </channel>
</rss>

