<?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: Macro to create a directory in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-create-a-directory/m-p/646826#M193531</link>
    <description>&lt;P&gt;&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=hostwin&amp;amp;docsetTarget=n0xwt90ik8vxdrn13708w6n3nm4o.htm&amp;amp;locale=en" target="_blank" rel="noopener"&gt;XWAIT System Option&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=mcrolref&amp;amp;docsetTarget=p07ugdul4v0llpn1denhfknmr7sb.htm&amp;amp;locale=en" target="_blank" rel="noopener"&gt;SYSRC Automatic Macro Variable&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 11 May 2020 17:51:10 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2020-05-11T17:51:10Z</dc:date>
    <item>
      <title>Macro to create a directory</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-create-a-directory/m-p/646823#M193528</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro CheckandCreateDir(dir);
&amp;nbsp;&amp;nbsp; options noxwait;
&amp;nbsp;&amp;nbsp; %local rc fileref ;
&amp;nbsp;&amp;nbsp; %let rc = %sysfunc(filename(fileref,&amp;amp;dir)) ;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp; %if %sysfunc(fexist(&amp;amp;fileref)) %then
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %put The directory "&amp;amp;dir" already exists ;
&amp;nbsp;&amp;nbsp; %else
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %do ;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %sysexec mkdir "&amp;amp;dir" ;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %if &amp;amp;sysrc eq 0 %then %put The directory &amp;amp;dir has been created;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;SPAN&gt;Can anyone briefly explain what's going on. &lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;SPAN&gt;I understood its creating a directory and checking whether it exits with IF ELSE statements. &lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;SPAN&gt;but am not sure what exactly NOXWAIT option and in the very last IF statement &amp;amp;sysrc is doing ?&lt;/SPAN&gt;&lt;/CODE&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="macrodir.PNG" style="width: 767px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/39303i2888F74FCB98E58F/image-size/large?v=v2&amp;amp;px=999" role="button" title="macrodir.PNG" alt="macrodir.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 11 May 2020 17:52:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-create-a-directory/m-p/646823#M193528</guid>
      <dc:creator>RAVI2000</dc:creator>
      <dc:date>2020-05-11T17:52:55Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to create a directory</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-create-a-directory/m-p/646824#M193529</link>
      <description>Can anyone briefly explain what's going on. I understood its creating a directory and checking whether it exits with IF ELSE statements. but am not sure what exactly NOXWAIT option and in the very last IF statement &amp;amp;sysrc is doing ?</description>
      <pubDate>Mon, 11 May 2020 17:45:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-create-a-directory/m-p/646824#M193529</guid>
      <dc:creator>RAVI2000</dc:creator>
      <dc:date>2020-05-11T17:45:58Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to create a directory</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-create-a-directory/m-p/646825#M193530</link>
      <description>&lt;P&gt;And what is your question?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please post code as text by copying it into a window opened with the "little running man" icon.&lt;/P&gt;</description>
      <pubDate>Mon, 11 May 2020 17:46:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-create-a-directory/m-p/646825#M193530</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-05-11T17:46:19Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to create a directory</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-create-a-directory/m-p/646826#M193531</link>
      <description>&lt;P&gt;&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=hostwin&amp;amp;docsetTarget=n0xwt90ik8vxdrn13708w6n3nm4o.htm&amp;amp;locale=en" target="_blank" rel="noopener"&gt;XWAIT System Option&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=mcrolref&amp;amp;docsetTarget=p07ugdul4v0llpn1denhfknmr7sb.htm&amp;amp;locale=en" target="_blank" rel="noopener"&gt;SYSRC Automatic Macro Variable&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 May 2020 17:51:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-create-a-directory/m-p/646826#M193531</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-05-11T17:51:10Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to create a directory</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-create-a-directory/m-p/646832#M193534</link>
      <description>What is the difference ? what exactly is it doing in the above program ?&lt;BR /&gt;&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=lefunctionsref&amp;amp;docsetTarget=n1xxj8ih9sjbznn1r17pgxuf8kpr.htm&amp;amp;locale=en" target="_blank"&gt;https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=lefunctionsref&amp;amp;docsetTarget=n1xxj8ih9sjbznn1r17pgxuf8kpr.htm&amp;amp;locale=en&lt;/A&gt;</description>
      <pubDate>Mon, 11 May 2020 18:02:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-create-a-directory/m-p/646832#M193534</guid>
      <dc:creator>RAVI2000</dc:creator>
      <dc:date>2020-05-11T18:02:57Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to create a directory</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-create-a-directory/m-p/646841#M193537</link>
      <description>&lt;P&gt;The documentation you linked is about the SYSRC()&amp;nbsp;&lt;EM&gt;data step function&lt;/EM&gt;, not the automatic macro variable, but both do in essence the same thing: report the return code of certain interactions with the operating system.&lt;/P&gt;
&lt;P&gt;In your code, the %IF where &amp;amp;SYSRC is used checks if the external call to mkdir succeeded. Today you would use the&amp;nbsp;&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=lefunctionsref&amp;amp;docsetTarget=p1aj29pf4cxnirn15q5hmf0tv438.htm&amp;amp;locale=en" target="_blank" rel="noopener"&gt;DCREATE()&lt;/A&gt;&amp;nbsp;data step function instead.&lt;/P&gt;</description>
      <pubDate>Mon, 11 May 2020 18:13:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-create-a-directory/m-p/646841#M193537</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-05-11T18:13:44Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to create a directory</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-create-a-directory/m-p/646882#M193551</link>
      <description>&lt;P&gt;This is an old macro that is &lt;STRONG&gt;NO&lt;/STRONG&gt; longer required in SAS. You can use either DCREATE() or the option on the libname statement to create the folder.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS is an old language so it's easy to find old stuff - 30 years old sometimes around.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've commend the code below but it's only partial code that you've posted.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;%macro CheckandCreateDir(dir);
   *if you don't have this option a dos window will pop up and you have to exit it manually;
   options noxwait;
   *creates a local macro variable;
   %local rc fileref ;
   *captures the Return Code (RC) from creating a filename reference;
   *check the documentation to see what the differnet return codes mean;
   %let rc = %sysfunc(filename(fileref,&amp;amp;dir)) ;   
   *checks if it already exists;
   %if %sysfunc(fexist(&amp;amp;fileref)) %then
      %put The directory "&amp;amp;dir" already exists ;
   %else
     %do ;
    *if it does not exist it makes the directory using a mkdir command;
         %sysexec mkdir "&amp;amp;dir" ;
         %if &amp;amp;sysrc eq 0 %then %put The directory &amp;amp;dir has been created;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 May 2020 20:57:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-create-a-directory/m-p/646882#M193551</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-05-11T20:57:36Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to create a directory</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-create-a-directory/m-p/646909#M193557</link>
      <description>&lt;P&gt;One of the nicer thing about the old SAS code you find, especially related to file manipulation or data step, is that most of it still works.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am glad that I don't have to "forget" the coding I learned for SAS in the 1980's. Unlike when I worked in a shop that used SPSS where every annual update cycle seemed to require redesigning code and rewriting because one or more of the key elements our shop used was removed or the syntax drastically changed.&lt;/P&gt;</description>
      <pubDate>Mon, 11 May 2020 23:29:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-create-a-directory/m-p/646909#M193557</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-05-11T23:29:14Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to create a directory</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-create-a-directory/m-p/646931#M193563</link>
      <description>Most definitely! Backwards compatibility helps you keep customers for sure. &lt;BR /&gt;But replace 30 lines of code for something when there's a one liner option in the 9.4 version is also nice. STACKODS from PROC MEANS is one of those options as are things like INDSNAME and colon operator.</description>
      <pubDate>Tue, 12 May 2020 02:34:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-create-a-directory/m-p/646931#M193563</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-05-12T02:34:19Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to create a directory</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-create-a-directory/m-p/646969#M193577</link>
      <description>&lt;P&gt;When things are built rather well from the start, there's no need for up-ending everything.&lt;/P&gt;
&lt;P&gt;All books I ever bought about things Microsoft have long gone into the recycling bin, but Ken Thompson's The UNIX Operating System and the classic Kernighan-Richie are still useful parts of my bookshelf.&lt;/P&gt;</description>
      <pubDate>Tue, 12 May 2020 05:49:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-create-a-directory/m-p/646969#M193577</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-05-12T05:49:47Z</dc:date>
    </item>
  </channel>
</rss>

