<?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 auto check in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-auto-check/m-p/651675#M195555</link>
    <description>&lt;P&gt;You will have to create a directory listing and then you SAS code to process the directories that actually exist.&lt;/P&gt;
&lt;P&gt;How to exactly do that will depend on whether your directories are on a Unix/Linus file system or on Windows and if option XCMD is enabled or not (is it XMCD or NOXCMD).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you're after dynamic code that creates single list of all customers in a single call of the program then you need also to provide the folder names of the customers, like: &amp;lt;some root path&amp;gt;/customer folders/&amp;lt;date folder&amp;gt;/&amp;lt;file name&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If&amp;nbsp; option XCMD is enabled (check via: Proc Options option=xmcd; run;) then first step is to get the listing working out of a command prompt (using DIR for Windows or LS for Unix/Linus).&lt;/P&gt;</description>
    <pubDate>Fri, 29 May 2020 09:59:20 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2020-05-29T09:59:20Z</dc:date>
    <item>
      <title>Macro auto check</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-auto-check/m-p/651667#M195551</link>
      <description>&lt;P&gt;Good day,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have 5 customers. &amp;nbsp; (A,B,C,D,E)&amp;nbsp;&lt;/P&gt;&lt;P&gt;* for each customer I have a folder with their monthly orders , named Orders_202001 , Orders_202002 etc.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem I have is not all customers started in 202001, some might have started 201905 or 202004. What I want to do is combine each customers order datasets into 1 list , but the code should be the same code. The code needs to look and wherever the order datasets start and end it must know. &amp;nbsp;&lt;/P&gt;&lt;P&gt;Customer A will have Orders_202001 to Orders_202005 &amp;nbsp; the code should be the same code I use for B,C,D and E but I do not want to tell the code when order datasets started and ended, it must know and process all the order datasets where data like "customer_order_%"&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am testing the code only on one customer, if it works for customer A it will work for the rest.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please can someone try and assist me ?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 May 2020 09:17:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-auto-check/m-p/651667#M195551</guid>
      <dc:creator>MadMax</dc:creator>
      <dc:date>2020-05-29T09:17:30Z</dc:date>
    </item>
    <item>
      <title>Re: Macro auto check</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-auto-check/m-p/651675#M195555</link>
      <description>&lt;P&gt;You will have to create a directory listing and then you SAS code to process the directories that actually exist.&lt;/P&gt;
&lt;P&gt;How to exactly do that will depend on whether your directories are on a Unix/Linus file system or on Windows and if option XCMD is enabled or not (is it XMCD or NOXCMD).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you're after dynamic code that creates single list of all customers in a single call of the program then you need also to provide the folder names of the customers, like: &amp;lt;some root path&amp;gt;/customer folders/&amp;lt;date folder&amp;gt;/&amp;lt;file name&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If&amp;nbsp; option XCMD is enabled (check via: Proc Options option=xmcd; run;) then first step is to get the listing working out of a command prompt (using DIR for Windows or LS for Unix/Linus).&lt;/P&gt;</description>
      <pubDate>Fri, 29 May 2020 09:59:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-auto-check/m-p/651675#M195555</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-05-29T09:59:20Z</dc:date>
    </item>
    <item>
      <title>Re: Macro auto check</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-auto-check/m-p/651829#M195599</link>
      <description>&lt;P&gt;Instead of using an operating system command, as suggested by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;, I would use the DOPEN and DREAD functions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;E.g.:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro read_dir(customer);
  Filename cust_dir "/dir/&amp;amp;customer"; /* This should be the actual location of the customer's folders */
  %local I dir_ID foldername month;
  %let dir_ID=%sysfunc(dopen(cust_dir));
  %do I=1 %to %sysfunc(dnum(&amp;amp;dir_ID));
    %let foldername=%sysfunc(dread(&amp;amp;dir_ID,&amp;amp;i));
    %let month=%substr(&amp;amp;foldername,8);
    libname monthly "/dir/&amp;amp;customer/&amp;amp;foldername";
    data temp;
      set monthly.orders; /* or whatever your dataset is called */
      length month $20;
      retain month "&amp;amp;month";
    run;
    proc append base=Cust_&amp;amp;customer data=temp;
    run;
    %end;
  %let dir_ID=%sysfunc(dclose(&amp;amp;dir_ID));
%mend;
     &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 29 May 2020 18:41:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-auto-check/m-p/651829#M195599</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2020-05-29T18:41:10Z</dc:date>
    </item>
  </channel>
</rss>

