<?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: DLCreatedir not working in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/DLCreatedir-not-working/m-p/573619#M12547</link>
    <description>&lt;P&gt;If&amp;nbsp; you are running on Unix and can run operating system commands from SAS then make the directory yourself.&amp;nbsp; The -p option on mkdir will attempt to make the intermediate directories.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%Let Year = 2019;
%let path=\\server1\UnitedStates\Health\year&amp;amp;YEAR.\state\California\;
data _null_;
  infile "mkdir -p &amp;amp;path" pipe;
  input;
  put _infile_;
run;
 
Libname WANT "&amp;amp;path";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 15 Jul 2019 17:56:20 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2019-07-15T17:56:20Z</dc:date>
    <item>
      <title>DLCreatedir not working</title>
      <link>https://communities.sas.com/t5/New-SAS-User/DLCreatedir-not-working/m-p/573583#M12535</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Suppose I have the following, where I want to create a 3 folders called "year2019", "state", and "California":&lt;/P&gt;&lt;P&gt;----------------------------------------------------------------------------------&lt;/P&gt;&lt;P&gt;Options dlcreatedir;&lt;/P&gt;&lt;P&gt;%Let Year = 2019;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Libname WANT "\\server1\UnitedStates\Health\year&amp;amp;YEAR.\state\California\";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;---------------------------------------------------------------------------------&lt;/P&gt;&lt;P&gt;The above code gives me the following error: Create of library WANT failed. Error in LIBNAME statement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, if I keep the exact code and run it in a piecemeal fashion then it surprisingly&amp;nbsp;works!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, in the first run I can just&amp;nbsp;highlight &amp;amp; run&amp;nbsp;"Libname WANT "\\server1\UnitedStates\Health\year&amp;amp;YEAR.\";&lt;/P&gt;&lt;P&gt;In the 2nd run,&amp;nbsp;I can highlight &amp;amp; run "Libname WANT "\\server1\UnitedStates\Health\year&amp;amp;YEAR.\state\" ;&lt;/P&gt;&lt;P&gt;In my final run,&amp;nbsp;I can highlight and run "Libname WANT "\\server1\UnitedStates\Health\year&amp;amp;YEAR.\state\California\";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Even though the text of the code hasn't changed, it only runs successfully if I run it folder by folder. Any way to get the option to work for the whole file path so that three folders are create immediately?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is appreciated.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jul 2019 16:26:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/DLCreatedir-not-working/m-p/573583#M12535</guid>
      <dc:creator>LFern</dc:creator>
      <dc:date>2019-07-15T16:26:01Z</dc:date>
    </item>
    <item>
      <title>Re: DLCreatedir not working</title>
      <link>https://communities.sas.com/t5/New-SAS-User/DLCreatedir-not-working/m-p/573593#M12536</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Options dlcreatedir;

%Let Year = 2019;

Libname WANT ("\\server1\UnitedStates\Health\year&amp;amp;YEAR.", "\\server1\UnitedStates\Health\year&amp;amp;YEAR.\state", "\\server1\UnitedStates\Health\year&amp;amp;YEAR.\state\California\");&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This should accomplish the results you are expecting.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Reference page: &lt;A href="https://blogs.sas.com/content/sasdummy/2013/07/02/use-dlcreatedir-to-create-folders/" target="_self"&gt;https://blogs.sas.com/content/sasdummy/2013/07/02/use-dlcreatedir-to-create-folders/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jul 2019 16:41:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/DLCreatedir-not-working/m-p/573593#M12536</guid>
      <dc:creator>tsap</dc:creator>
      <dc:date>2019-07-15T16:41:41Z</dc:date>
    </item>
    <item>
      <title>Re: DLCreatedir not working</title>
      <link>https://communities.sas.com/t5/New-SAS-User/DLCreatedir-not-working/m-p/573595#M12537</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/262848"&gt;@LFern&lt;/a&gt;&amp;nbsp;I would think about it like this.&lt;/P&gt;&lt;P&gt;For the California folder to be created, first State folder has to be ready and before that y&lt;SPAN&gt;ear&amp;amp;YEAR. folder has to be ready. When you are trying to create&amp;nbsp;&amp;nbsp;"Libname WANT "\\server1\UnitedStates\Health\year&amp;amp;YEAR.\state\California\" at once the preceeding folders are not ready.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I would have done it in three statements (as has already worked for you).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Libname WANT "\\server1\UnitedStates\Health\year&amp;amp;YEAR.\";

Libname WANT "\\server1\UnitedStates\Health\year&amp;amp;YEAR.\state\" ;

Libname WANT "\\server1\UnitedStates\Health\year&amp;amp;YEAR.\state\California\";&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Having said that...there might be a shortcut, actually (which I am unaware of). One thing I have learnt is that there is more than one way to do it in SAS.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jul 2019 16:45:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/DLCreatedir-not-working/m-p/573595#M12537</guid>
      <dc:creator>koyelghosh</dc:creator>
      <dc:date>2019-07-15T16:45:08Z</dc:date>
    </item>
    <item>
      <title>Re: DLCreatedir not working</title>
      <link>https://communities.sas.com/t5/New-SAS-User/DLCreatedir-not-working/m-p/573597#M12538</link>
      <description>There is a shortcut...I can't recall what now, but there's a way to have it create the folders above as well....DCREATE can also be used within a macro loop to automate this. I think there's a few of those floating around if you search. If you have XCMD enabled, using mkdir is another option.</description>
      <pubDate>Mon, 15 Jul 2019 16:48:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/DLCreatedir-not-working/m-p/573597#M12538</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-07-15T16:48:11Z</dc:date>
    </item>
    <item>
      <title>Re: DLCreatedir not working</title>
      <link>https://communities.sas.com/t5/New-SAS-User/DLCreatedir-not-working/m-p/573609#M12543</link>
      <description>&lt;P&gt;From the documentation it clearly describes what is going on:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;TABLE class="xis-summary"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="xis-restriction"&gt;Restriction&lt;/TD&gt;
&lt;TD class="xis-summaryText"&gt;If the path specified in the LIBNAME statement contains &lt;STRONG&gt;multiple components&lt;/STRONG&gt;, SAS creates only the final component in the path. If any intermediate components of the path do not exist, SAS does not assign the specified path. For example, when the code &lt;CODE class="xis-codeDefaultStyle"&gt;libname                                    mytestdir ‘c:\mysasprograms\test’&lt;/CODE&gt; executes, and c:\mysasprograms exists, SAS creates the test directory. If c:\mysasprograms does not exist, SAS does not create the test directory.&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;My emphasis added on multiple components.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jul 2019 17:25:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/DLCreatedir-not-working/m-p/573609#M12543</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-07-15T17:25:27Z</dc:date>
    </item>
    <item>
      <title>Re: DLCreatedir not working</title>
      <link>https://communities.sas.com/t5/New-SAS-User/DLCreatedir-not-working/m-p/573619#M12547</link>
      <description>&lt;P&gt;If&amp;nbsp; you are running on Unix and can run operating system commands from SAS then make the directory yourself.&amp;nbsp; The -p option on mkdir will attempt to make the intermediate directories.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%Let Year = 2019;
%let path=\\server1\UnitedStates\Health\year&amp;amp;YEAR.\state\California\;
data _null_;
  infile "mkdir -p &amp;amp;path" pipe;
  input;
  put _infile_;
run;
 
Libname WANT "&amp;amp;path";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jul 2019 17:56:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/DLCreatedir-not-working/m-p/573619#M12547</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-07-15T17:56:20Z</dc:date>
    </item>
  </channel>
</rss>

