<?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 include all .sas file from a folder in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-include-all-sas-file-from-a-folder/m-p/745040#M233497</link>
    <description>&lt;P&gt;From a later post of yours I see you are using SAS on UNIX, so&lt;/P&gt;
&lt;PRE&gt;dir /s /b&lt;/PRE&gt;
&lt;P&gt;can't work at all.&lt;/P&gt;
&lt;P&gt;dir has to be a shell script or an alias mimicking the DOS command, but it does not "understand" the same options or the same syntax. And there will not be a Z: drive on UNIX ever, as these systems do not have the concept of drives, they have a single filesystem starting at root (/) where all resources need to be mounted.&lt;/P&gt;
&lt;P&gt;So I guess the re-ordering of the characters is a consequence of the mistaken use of a Windows path.&lt;/P&gt;</description>
    <pubDate>Tue, 01 Jun 2021 22:15:29 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2021-06-01T22:15:29Z</dc:date>
    <item>
      <title>Macro to include all .sas file from a folder</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-include-all-sas-file-from-a-folder/m-p/742280#M232150</link>
      <description>&lt;P&gt;I am having multiple study folders which again have multiple folders for rawdata. In them, are my .sas files to input the rawdata. The .sas files have infile statement that includes \ (back slash) and while I am running them I get error since I am running them on unix environment. The macro should also convert the \ to / in the infile statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Project1&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ----&amp;gt;rawdata&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;----&amp;gt;dm&lt;/P&gt;
&lt;P&gt;&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;gt; dm.csv (rawdata)&lt;/P&gt;
&lt;P&gt;&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;gt;dm.sas (is including the dm.csv rawdata file and creating the formats in&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ----&amp;gt;ae&lt;/P&gt;
&lt;P&gt;&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;gt; ae.csv (rawdata)&lt;/P&gt;
&lt;P&gt;&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;gt;ae.sas (is including the ae.csv rawdata file and creating the formats in .sas file)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;---&amp;gt;cm&lt;/P&gt;
&lt;P&gt;&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;gt;cm.csv (rawdata)&lt;/P&gt;
&lt;P&gt;&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;gt;cm.sas (is including the cm.csv rawdata and creating the formats in .sas file)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;---&amp;gt;ex&lt;/P&gt;
&lt;P&gt;&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; &amp;nbsp; &amp;nbsp;similar&lt;/P&gt;
&lt;P&gt;&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; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/P&gt;
&lt;P&gt;&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; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/P&gt;
&lt;P&gt;&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; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/P&gt;
&lt;P&gt;The sample dm.sas file to read the .csv file&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.DEMOGRAPHICS frmts.DEMOGRAPHICS;
  %let _EFIERR_ = 0;
  infile '.\Demographics.txt' delimiter='09'x MISSOVER DSD lrecl=32767 firstobs=2 termstr=CRLF;
 INPUT SEQUENCE_NO  BIRTH_DATE AGE_ON_STUDY GENDER RACE ETHNICITY ELIGIBILITY_STATUS ON_STUDY_DATE ARMS;
if _ERROR_ then call symput('_EFIERR_',1);
run;

data DEMOGRAPHICS_FMT;
  set DEMOGRAPHICS;
run;
title "Demographics";
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I have these .sas files for all .csv files for multiple projects.&lt;/P&gt;
&lt;P&gt;Project2&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;----&amp;gt;rawdata&lt;/P&gt;
&lt;P&gt;&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;gt;ae&lt;/P&gt;
&lt;P&gt;&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; &amp;nbsp; &amp;nbsp; ----&amp;gt; ae.csv (rawdata)&lt;/P&gt;
&lt;P&gt;&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; &amp;nbsp; &amp;nbsp; ----&amp;gt;ae.sas (is including the ae.csv rawdata file and creating the formats in .sas file)&lt;/P&gt;
&lt;P&gt;&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;gt;cm&lt;/P&gt;
&lt;P&gt;&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; &amp;nbsp; &amp;nbsp; ---&amp;gt;cm.csv (rawdata)&lt;/P&gt;
&lt;P&gt;&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; &amp;nbsp; &amp;nbsp; ---&amp;gt;cm.sas (is including the cm.csv rawdata and creating the formats in .sas file)&lt;/P&gt;
&lt;P&gt;&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;gt;ex&lt;/P&gt;
&lt;P&gt;&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; &amp;nbsp; &amp;nbsp;similar&lt;/P&gt;
&lt;P&gt;&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; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/P&gt;
&lt;P&gt;&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; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/P&gt;
&lt;P&gt;&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; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/P&gt;
&lt;P&gt;I want to run all the .sas files in batch mode to get the raw datasets.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have did the below to convert the \ to /, but for just one single .sas file. How do I do for all .sas file?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename fixed '/Studies/Project1/rawdata/AE.sas';
data _null_;
  infile fixed;
  file fixed ;
  input;
  if left(upcase(_infile_))=:'INFILE' then _infile_=translate(_infile_,'/','\');
  put _infile_;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;How can I run all .sas file with multiple project folders?&lt;/P&gt;
&lt;P&gt;Please let me know if you need any additional information.&lt;/P&gt;
&lt;P&gt;PS: I am&lt;SPAN&gt;&amp;nbsp;using SAS on UNIX, and all these projects are in a shared folder drive "z".&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Aug 2021 19:03:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-include-all-sas-file-from-a-folder/m-p/742280#M232150</guid>
      <dc:creator>RAVI2000</dc:creator>
      <dc:date>2021-08-24T19:03:09Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to include all .sas file from a folder</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-include-all-sas-file-from-a-folder/m-p/742282#M232151</link>
      <description>&lt;P&gt;Since programs tend to need to run in a specific order how do you control the order these %include files should execute?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the code only creates formats and does not change then you should&lt;/P&gt;
&lt;P&gt;1) create a permanent library to store the formats&lt;/P&gt;
&lt;P&gt;2) make sure the formats are stored in that library : proc format libname=yourlib; for example&lt;/P&gt;
&lt;P&gt;3) After that is done you only need one statement to make sure the formats are available by adding the library to the FMTSEARCH path. Something like: Options append=(fmtsearch(yourlib));&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 May 2021 21:24:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-include-all-sas-file-from-a-folder/m-p/742282#M232151</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-05-18T21:24:33Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to include all .sas file from a folder</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-include-all-sas-file-from-a-folder/m-p/742283#M232152</link>
      <description>&lt;P&gt;1. Find all your .SAS files using a network directory call. This is &lt;A href="https://communities.sas.com/t5/SAS-Programming/List-of-Files-in-Directory-and-Subdirectories-with-File/td-p/696059" target="_self"&gt;asked and answered on here weekly&lt;/A&gt; so a &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/List-of-Directories-and-Files-in-Linux/ta-p/582142" target="_self"&gt;search&lt;/A&gt; should find you results. Store them in a data set. I assume that your programs can be run in alphabetical order of the folders? If not, and a specific order is required, how is that determined?&lt;BR /&gt;2. Use CALL EXECUTE to %include each file &lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
set list_files;
str = catt('%include "',
file_path,
'" / source;');
call execute(str);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/294544"&gt;@RAVI2000&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have a folder which again has multiple folders. In them, are my .sas file.&lt;/P&gt;
&lt;P&gt;Project1&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;----&amp;gt;rawdata&lt;/P&gt;
&lt;P&gt;&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;gt;ae&lt;/P&gt;
&lt;P&gt;&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; &amp;nbsp; &amp;nbsp; ----&amp;gt; ae.txt (rawdata)&lt;/P&gt;
&lt;P&gt;&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; &amp;nbsp; &amp;nbsp; ----&amp;gt;ae.sas (is including the ae.txt rawdata file and creating the formats in .sas file)&lt;/P&gt;
&lt;P&gt;&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;gt;cm&lt;/P&gt;
&lt;P&gt;&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; &amp;nbsp; &amp;nbsp; ---&amp;gt;cm.txt(rawdata)&lt;/P&gt;
&lt;P&gt;&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; &amp;nbsp; &amp;nbsp; ---&amp;gt;cm.sas (is including the cm.txt rawdata and creating the formats in .sas file)&lt;/P&gt;
&lt;P&gt;&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;gt;ex&lt;/P&gt;
&lt;P&gt;&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; &amp;nbsp; &amp;nbsp;similar&lt;/P&gt;
&lt;P&gt;&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; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/P&gt;
&lt;P&gt;&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; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/P&gt;
&lt;P&gt;&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; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/P&gt;
&lt;P&gt;So, clearly it has different individual .sas files for formats in individual subfolders. I want a macro that can include all the .sas format files that I can use in the program. Please let me know if you need any additional information.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 18 May 2021 21:28:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-include-all-sas-file-from-a-folder/m-p/742283#M232152</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-05-18T21:28:19Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to include all .sas file from a folder</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-include-all-sas-file-from-a-folder/m-p/742297#M232158</link>
      <description>&lt;P&gt;One easy way to ensure your programs run in the correct order is to add a number to the start of your program names like so:&lt;/P&gt;
&lt;P&gt;ae.sas ==&amp;gt; 010_ae.sas&lt;/P&gt;
&lt;P&gt;cm.sas ==&amp;gt; 020_cm.sas&lt;/P&gt;
&lt;P&gt;ex.sas ==&amp;gt; 030_ex.sas&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you sort by program name these will always be in run order.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 May 2021 22:31:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-include-all-sas-file-from-a-folder/m-p/742297#M232158</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2021-05-18T22:31:08Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to include all .sas file from a folder</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-include-all-sas-file-from-a-folder/m-p/742387#M232214</link>
      <description>&lt;P&gt;Usine OS command to get all these sas code. and Call execute() to execute it .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename x pipe 'dir c:\temp\*.sas /s /b';
data _null_;
infile x;
input ;
put _infile_;
/*call execute(catt('%include "',_infile_,'";'));*/
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 May 2021 12:25:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-include-all-sas-file-from-a-folder/m-p/742387#M232214</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-05-19T12:25:09Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to include all .sas file from a folder</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-include-all-sas-file-from-a-folder/m-p/742426#M232240</link>
      <description>I don't have a specific order for them. Is it necessary that they have to be in order?</description>
      <pubDate>Wed, 19 May 2021 14:57:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-include-all-sas-file-from-a-folder/m-p/742426#M232240</guid>
      <dc:creator>RAVI2000</dc:creator>
      <dc:date>2021-05-19T14:57:18Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to include all .sas file from a folder</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-include-all-sas-file-from-a-folder/m-p/742428#M232241</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/294544"&gt;@RAVI2000&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;I don't have a specific order for them. Is it necessary that they have to be in order?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Depends on what they DO.&lt;/P&gt;</description>
      <pubDate>Wed, 19 May 2021 14:59:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-include-all-sas-file-from-a-folder/m-p/742428#M232241</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-05-19T14:59:14Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to include all .sas file from a folder</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-include-all-sas-file-from-a-folder/m-p/742456#M232258</link>
      <description>Hello Tom, can you explain me your code in detail. I am not catching it.&lt;BR /&gt;data filelist;&lt;BR /&gt;  length dname filename $256 dir level 8 lastmod size 8;&lt;BR /&gt;  format lastmod datetime20.;&lt;BR /&gt;  input dname;&lt;BR /&gt;  retain filename ' ' level 0 dir 1;&lt;BR /&gt;cards4;&lt;BR /&gt;/folders/myfolders&lt;BR /&gt;;;;;&lt;BR /&gt;&lt;BR /&gt;data filelist;&lt;BR /&gt;  modify filelist;&lt;BR /&gt;  rc1=filename('tmp',catx('/',dname,filename));&lt;BR /&gt;  rc2=dopen('tmp');&lt;BR /&gt;  dir = not not rc2;&lt;BR /&gt;  if not dir then do;&lt;BR /&gt;    fid=fopen('tmp','i',0,'b');&lt;BR /&gt;    lastmod=input(finfo(fid,foptname(fid,5)),NLDATM100.);&lt;BR /&gt;    size=input(finfo(fid,foptname(fid,6)),32.);&lt;BR /&gt;    fid=fclose(fid);&lt;BR /&gt;  end;&lt;BR /&gt;  else do;&lt;BR /&gt;    dname=catx('/',dname,filename);&lt;BR /&gt;    filename=' ';&lt;BR /&gt;    lastmod=input(dinfo(rc2,doptname(rc2,5)),NLDATM100.);&lt;BR /&gt;  end;&lt;BR /&gt;  replace;&lt;BR /&gt;  if dir;&lt;BR /&gt;  level=level+1;&lt;BR /&gt;  do i=1 to dnum(rc2);&lt;BR /&gt;    filename=dread(rc2,i);&lt;BR /&gt;    output;&lt;BR /&gt;  end;&lt;BR /&gt;  rc3=dclose(rc2);&lt;BR /&gt;run;</description>
      <pubDate>Wed, 19 May 2021 15:57:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-include-all-sas-file-from-a-folder/m-p/742456#M232258</guid>
      <dc:creator>RAVI2000</dc:creator>
      <dc:date>2021-05-19T15:57:52Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to include all .sas file from a folder</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-include-all-sas-file-from-a-folder/m-p/742459#M232261</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First step is to create a dataset that has the full structure for storing the directory contents information.&amp;nbsp; It also has one observation for every top level path you want to traverse.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The second step use the MODIFY statement to allow you to process this dataset and add observations to it at the same time.&amp;nbsp; As you output more observations they are added to the end and so will get re-processed by this same data step as new input records.&amp;nbsp; This is the "secret sauce" that let's essentially do recursion.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The guts of the data step will&lt;/P&gt;
&lt;P&gt;1) Create a fileref TMP pointing to the current file.&lt;/P&gt;
&lt;P&gt;2) Try to open that fileref as if it was a directory.&amp;nbsp; This is what detects any subdirectories (including the original top level nodes).&lt;/P&gt;
&lt;P&gt;3) Set the DIR flag variable to true (1) when the file is a directory.&lt;/P&gt;
&lt;P&gt;4) Based on whether or not it is a directory it uses different paths to gather information on the file.&lt;/P&gt;
&lt;P&gt;5) It replaces the current observation in the dataset. (so it updates those other variables).&lt;/P&gt;
&lt;P&gt;6) When it is a directory it adds new observations for all of the files in the directory. The new observations will then be processed by steps 1-5 in the later iterations of the data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For more details look up the functions being used.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note: Removing the indentation like in your post makes it harder to read the code.&lt;/P&gt;</description>
      <pubDate>Wed, 19 May 2021 16:13:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-include-all-sas-file-from-a-folder/m-p/742459#M232261</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-05-19T16:13:18Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to include all .sas file from a folder</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-include-all-sas-file-from-a-folder/m-p/742467#M232266</link>
      <description>&lt;P&gt;See this thread for more discussion and a more complete version of this code at the end from&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/Size-of-a-directory/m-p/642202/highlight/true#M191554" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/Size-of-a-directory/m-p/642202/highlight/true#M191554&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 May 2021 16:32:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-include-all-sas-file-from-a-folder/m-p/742467#M232266</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-05-19T16:32:49Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to include all .sas file from a folder</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-include-all-sas-file-from-a-folder/m-p/744275#M233161</link>
      <description>Hello &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;, &lt;BR /&gt;Thank you for your input! &lt;BR /&gt;I was trying your code my using my folder directory. It is not working. I am attaching my code for you reference. Please correct me where I am wrong.&lt;BR /&gt;&lt;BR /&gt;filename x pipe 'dir Z:\Trials\ProjectA\RawData\DSMC_Datacutoff_20210316\StudyData-20210316\*.sas /s /b';&lt;BR /&gt;data _null_;&lt;BR /&gt;infile x;&lt;BR /&gt;input ;&lt;BR /&gt;put _infile_;&lt;BR /&gt;/*call execute(catt('%include "',_infile_,'";'));*/&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;The StudyData-20210316 again has multiple folder like AE, LB, RESPONSE, etc., The .sas files are in each folder.&lt;BR /&gt;</description>
      <pubDate>Thu, 27 May 2021 19:20:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-include-all-sas-file-from-a-folder/m-p/744275#M233161</guid>
      <dc:creator>RAVI2000</dc:creator>
      <dc:date>2021-05-27T19:20:09Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to include all .sas file from a folder</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-include-all-sas-file-from-a-folder/m-p/744276#M233162</link>
      <description>Log.</description>
      <pubDate>Thu, 27 May 2021 19:24:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-include-all-sas-file-from-a-folder/m-p/744276#M233162</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-05-27T19:24:54Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to include all .sas file from a folder</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-include-all-sas-file-from-a-folder/m-p/744365#M233201</link>
      <description>Post your log. &lt;BR /&gt;And in log should display all these .sas filename .&lt;BR /&gt;&lt;BR /&gt;P.S Assuming your PIPE could be execute under SAS.</description>
      <pubDate>Fri, 28 May 2021 11:52:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-include-all-sas-file-from-a-folder/m-p/744365#M233201</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-05-28T11:52:45Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to include all .sas file from a folder</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-include-all-sas-file-from-a-folder/m-p/744475#M233236</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;23         filename x pipe 'dir
23       ! Z:\Trials\ProjectA\Data\DSMC_Datacutoff_20210316\StudyData-03-16-2021\*.sas /s /b'
23       ! ;
24         data _null_;
25         infile x;
26         input ;
27         put _infile_;
28         /*call execute(catt('%include "',_infile_,'";'));*/
29         run;

&amp;#12;2                                                          The SAS System                                 12:12 Friday, May 28, 2021

NOTE: The infile X is:
      
      Pipe command="dir 
      Z:\Trials\ProjectA\Data\DSMC_Datacutoff_20210521\StudyData-03-16-2021\*.sas /s /b"

dir: cannot access Z\:TrialsProjectADataDSMC_Datacutoff_20210316StudyData-03-16-2021*.sas: No
 such file or directory
dir: cannot access /s: No such file or directory
dir: cannot access /b: No such file or directory
NOTE: 3 records were read from the infile X.
      The minimum record length was 48.
      The maximum record length was 155.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds
      

NOTE: SAS Institute Inc., SAS Campus Drive, Cary, NC USA 27513-2414
NOTE: The SAS System used:
      real time           0.03 seconds
      cpu time            0.02 seconds&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 28 May 2021 17:16:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-include-all-sas-file-from-a-folder/m-p/744475#M233236</guid>
      <dc:creator>RAVI2000</dc:creator>
      <dc:date>2021-05-28T17:16:21Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to include all .sas file from a folder</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-include-all-sas-file-from-a-folder/m-p/744482#M233241</link>
      <description>Are you using SAS EG? Is it running on a server with access to the Z drive? Or is the Z drive a local drive for you?</description>
      <pubDate>Fri, 28 May 2021 17:41:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-include-all-sas-file-from-a-folder/m-p/744482#M233241</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-05-28T17:41:19Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to include all .sas file from a folder</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-include-all-sas-file-from-a-folder/m-p/744543#M233261</link>
      <description>I don't have sas on my windows. I use cisco connect which takes me to a remote desktop. There I run on UNIX using terminal and giving UNIX comands.</description>
      <pubDate>Fri, 28 May 2021 20:23:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-include-all-sas-file-from-a-folder/m-p/744543#M233261</guid>
      <dc:creator>RAVI2000</dc:creator>
      <dc:date>2021-05-28T20:23:12Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to include all .sas file from a folder</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-include-all-sas-file-from-a-folder/m-p/744544#M233262</link>
      <description>And the Z drive is where? That path looks like a Windows path not Unix path.</description>
      <pubDate>Fri, 28 May 2021 20:29:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-include-all-sas-file-from-a-folder/m-p/744544#M233262</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-05-28T20:29:26Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to include all .sas file from a folder</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-include-all-sas-file-from-a-folder/m-p/744937#M233446</link>
      <description>The folder is a shared folder which we have to map manually. Once I map it then only I am able to access it.</description>
      <pubDate>Tue, 01 Jun 2021 13:49:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-include-all-sas-file-from-a-folder/m-p/744937#M233446</guid>
      <dc:creator>RAVI2000</dc:creator>
      <dc:date>2021-06-01T13:49:37Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to include all .sas file from a folder</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-include-all-sas-file-from-a-folder/m-p/744941#M233447</link>
      <description>&lt;PRE&gt;Z\:&lt;/PRE&gt;
&lt;P&gt;is incorrect syntax. The colon has to immediately follow the drive letter:&lt;/P&gt;
&lt;PRE&gt;Z:\&lt;/PRE&gt;</description>
      <pubDate>Tue, 01 Jun 2021 14:07:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-include-all-sas-file-from-a-folder/m-p/744941#M233447</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-06-01T14:07:02Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to include all .sas file from a folder</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-include-all-sas-file-from-a-folder/m-p/744994#M233479</link>
      <description>Thank you for the input Kurt! But if you observe my log, I have given it correctly. But SAS is reading it like this Z\:&lt;BR /&gt;&lt;BR /&gt;How can I correct it?</description>
      <pubDate>Tue, 01 Jun 2021 17:28:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-include-all-sas-file-from-a-folder/m-p/744994#M233479</guid>
      <dc:creator>RAVI2000</dc:creator>
      <dc:date>2021-06-01T17:28:36Z</dc:date>
    </item>
  </channel>
</rss>

