<?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 dynamically creating folders in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/dynamically-creating-folders/m-p/263067#M269158</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a macro list with the names of 3 comapanies: A,B and C, and the variable for the compnies is "company"&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;for each company I would like to create a folder on my computer, and I use the following code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
do while &amp;amp;company ne ;
x "mkdir c:\test\&amp;amp;company";
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;On the other hand when I just do:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;x "mkdir c:\test\A";
x "mkdir c:\test\B";
x "mkdir c:\test\C";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I get the 3 folders as wanted, so it seems that there is a problem with my iteration.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;</description>
    <pubDate>Tue, 12 Apr 2016 03:13:54 GMT</pubDate>
    <dc:creator>ilikesas</dc:creator>
    <dc:date>2016-04-12T03:13:54Z</dc:date>
    <item>
      <title>dynamically creating folders</title>
      <link>https://communities.sas.com/t5/SAS-Programming/dynamically-creating-folders/m-p/263067#M269158</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a macro list with the names of 3 comapanies: A,B and C, and the variable for the compnies is "company"&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;for each company I would like to create a folder on my computer, and I use the following code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
do while &amp;amp;company ne ;
x "mkdir c:\test\&amp;amp;company";
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;On the other hand when I just do:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;x "mkdir c:\test\A";
x "mkdir c:\test\B";
x "mkdir c:\test\C";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I get the 3 folders as wanted, so it seems that there is a problem with my iteration.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 12 Apr 2016 03:13:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/dynamically-creating-folders/m-p/263067#M269158</guid>
      <dc:creator>ilikesas</dc:creator>
      <dc:date>2016-04-12T03:13:54Z</dc:date>
    </item>
    <item>
      <title>Re: dynamically creating folders</title>
      <link>https://communities.sas.com/t5/SAS-Programming/dynamically-creating-folders/m-p/263071#M269159</link>
      <description>&lt;P&gt;Your loop is specified incorrectly.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use dcreate as well, fyi.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What does your macro variable look like, resolve to? I'm not sure how you expect it to loop.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Apr 2016 02:06:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/dynamically-creating-folders/m-p/263071#M269159</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-04-12T02:06:50Z</dc:date>
    </item>
    <item>
      <title>Re: dynamically creating folders</title>
      <link>https://communities.sas.com/t5/SAS-Programming/dynamically-creating-folders/m-p/263073#M269160</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*Maybe you can skip the macro variable step, &lt;BR /&gt;assuming you create it from a list of companies in a dataset;&lt;BR /&gt;&lt;BR /&gt;data have;
input company $;
cards;
A
B
C
;
run;

data new_dirs;
set have;
new_dir= dcreate(company, "C:\test\");
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 12 Apr 2016 02:18:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/dynamically-creating-folders/m-p/263073#M269160</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-04-12T02:18:54Z</dc:date>
    </item>
    <item>
      <title>Re: dynamically creating folders</title>
      <link>https://communities.sas.com/t5/SAS-Programming/dynamically-creating-folders/m-p/263077#M269161</link>
      <description>&lt;P&gt;Hi Reeza,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;thnka sfor the code, I ran it but the column "new_dir" that it created was empty (and no new folders...).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Initially I had a data set "test" with many lines per company, then I extracted the unique comany names witht he following code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
create table companies as select distinct company into: cmlst separated by ' ' from test;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And then I did the my code...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 12 Apr 2016 03:13:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/dynamically-creating-folders/m-p/263077#M269161</guid>
      <dc:creator>ilikesas</dc:creator>
      <dc:date>2016-04-12T03:13:21Z</dc:date>
    </item>
    <item>
      <title>Re: dynamically creating folders</title>
      <link>https://communities.sas.com/t5/SAS-Programming/dynamically-creating-folders/m-p/263081#M269162</link>
      <description>&lt;P&gt;Post post your code and log.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
proc sql noprint;
create table companies as select distinct company from test;
quit;

Data want; 
Set companies; 
New_dir=Dcreate(company, 'C:\test\');
Run;  &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Also check your folder to see if they're created.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Apr 2016 03:20:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/dynamically-creating-folders/m-p/263081#M269162</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-04-12T03:20:26Z</dc:date>
    </item>
    <item>
      <title>Re: dynamically creating folders</title>
      <link>https://communities.sas.com/t5/SAS-Programming/dynamically-creating-folders/m-p/263088#M269163</link>
      <description>&lt;P&gt;Hi Reeza,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am getting very weired results:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Once I tried your sample code when the 3 companies were written in a data step and actually got the 3 folders!!! (and the paths to the directories were included in the new_dir).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then I wanted to do the same thing with my data but didn't get anything (and the new_dir is empty), and when wanted to re do your sample code also didn't get anything! There is no error message whatsoever.&lt;/P&gt;
&lt;P&gt;???&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 12 Apr 2016 03:53:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/dynamically-creating-folders/m-p/263088#M269163</guid>
      <dc:creator>ilikesas</dc:creator>
      <dc:date>2016-04-12T03:53:59Z</dc:date>
    </item>
    <item>
      <title>Re: dynamically creating folders</title>
      <link>https://communities.sas.com/t5/SAS-Programming/dynamically-creating-folders/m-p/263093#M269164</link>
      <description>&lt;P&gt;Hi Reeza,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;sorry for being so confusing but now it works all the time!!!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Its just that I realized that the directory "test" must already exist in order for the other directories to be put into it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Last time when your sample code worked and I wanted to redo it on my company data I actually deleted the "test" directory (which somehow I had from previous attempts) in order to see how the code fully works, and that's when I wasn't getting anything becasue from what now I understand the function DECREATE must be given a parent directory since it doesn't create the "full path" but rather only the "end of the line" directory.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your help and for making me discover DECREATE!!!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Apr 2016 04:16:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/dynamically-creating-folders/m-p/263093#M269164</guid>
      <dc:creator>ilikesas</dc:creator>
      <dc:date>2016-04-12T04:16:17Z</dc:date>
    </item>
    <item>
      <title>Re: dynamically creating folders</title>
      <link>https://communities.sas.com/t5/SAS-Programming/dynamically-creating-folders/m-p/263094#M269165</link>
      <description>&lt;P&gt;No, there is no,error message. Read the doc regarding the function.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your having issues you can use call system instead and build file path using CAT functions.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the folder already exists they won't get overwritten.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Apr 2016 04:16:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/dynamically-creating-folders/m-p/263094#M269165</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-04-12T04:16:47Z</dc:date>
    </item>
  </channel>
</rss>

