<?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: Run multiple .sas file by changing \ to / on sas unix in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Run-multiple-sas-file-by-changing-to-on-sas-unix/m-p/763954#M241953</link>
    <description>Sorry Kurt. I didn't quite catch you. I am trying everything and not a solution i am getting. It keep on says the directory doesn't exist. I am now exhausted!!!</description>
    <pubDate>Wed, 25 Aug 2021 18:45:22 GMT</pubDate>
    <dc:creator>RAVI2000</dc:creator>
    <dc:date>2021-08-25T18:45:22Z</dc:date>
    <item>
      <title>Run multiple .sas file by changing \ to / on sas unix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-multiple-sas-file-by-changing-to-on-sas-unix/m-p/763668#M241850</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&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 class="language-sas"&gt;&lt;CODE&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 class="language-sas"&gt;&lt;CODE&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:09:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-multiple-sas-file-by-changing-to-on-sas-unix/m-p/763668#M241850</guid>
      <dc:creator>RAVI2000</dc:creator>
      <dc:date>2021-08-24T19:09:03Z</dc:date>
    </item>
    <item>
      <title>Re: Run multiple .sas file by changing \ to / on sas unix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-multiple-sas-file-by-changing-to-on-sas-unix/m-p/763753#M241872</link>
      <description>&lt;P&gt;So you want to:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;1. Gather the list of files to modify&lt;/P&gt;
&lt;P&gt;&amp;nbsp;2. Alter the code to change \ to /&amp;nbsp;&lt;/P&gt;
&lt;P&gt;?&lt;/P&gt;
&lt;P&gt;Is that enough? Are the paths really otherwise identical?&lt;/P&gt;
&lt;P&gt;For 1.&amp;nbsp; See the pinned topic "&lt;A id="link_25" class="page-link lia-link-navigation lia-custom-event" href="https://communities.sas.com/t5/SAS-Programming/How-to-List-all-the-files-in-a-folder/td-p/674065/jump-to/first-unread-message" target="_blank" rel="noopener"&gt;How to: List all the files in a folder&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/A&gt;"&lt;/P&gt;
&lt;P&gt;For 2.&amp;nbsp; Your code looks fine. You could call it using &lt;FONT face="courier new,courier"&gt;call execute&lt;/FONT&gt; while reading the list of files fetched in 1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Comment: This could be avoided if paths were not hard-coded in programs, but were stored centrally.&lt;/P&gt;
&lt;P&gt;A basic way to do this is keep them in a set of programs and store them in pre-defined macro variables or FILENAMEs or LIBNAMEs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Aug 2021 22:40:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-multiple-sas-file-by-changing-to-on-sas-unix/m-p/763753#M241872</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-08-24T22:40:00Z</dc:date>
    </item>
    <item>
      <title>Re: Run multiple .sas file by changing \ to / on sas unix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-multiple-sas-file-by-changing-to-on-sas-unix/m-p/763933#M241945</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;NOTE: Libref SJ was successfully assigned as follows: 
      Engine:        V9 
      Physical Name: /data/Trials
2          data sj.filenames;
3          length fref $8 fname $200;
4          did = filename(fref,'/data/Trials/ae.sas');
5          did = dopen(fref);
6          do i = 1 to dnum(did);
7            fname = dread(did,i);
8            output;
9          end;
10         did = dclose(did);
11         did = filename(fref);
12         keep fname;
13         run;

NOTE: Argument 1 to function DNUM(0) at line 6 column 13 is invalid.
ERROR: Invalid DO loop control information, either the INITIAL or TO expression is missing or the BY expression is missing, zero, 
       or invalid.
fref=#LN00006 fname=  did=0 i=1 _ERROR_=1 _N_=1
NOTE: Mathematical operations could not be performed at the following places. The results of the operations have been set to 
      missing values.
      Each place is given by: (Number of times) at (Line):(Column).
      1 at 6:13   
NOTE: The SAS System stopped processing this step because of errors.
NOTE: Due to ERROR(s) above, SAS set option OBS=0, enabling syntax check mode. 
      This prevents execution of subsequent data modification statements.
WARNING: The data set SJ.FILENAMES may be incomplete.  When this step was stopped there were 0 observations and 1 variables.
WARNING: Data set SJ.FILENAMES was not replaced because this step was stopped.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I am running SAS on UNIX envi. Please look into the log and let me know where I am going wrong.&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 25 Aug 2021 17:44:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-multiple-sas-file-by-changing-to-on-sas-unix/m-p/763933#M241945</guid>
      <dc:creator>RAVI2000</dc:creator>
      <dc:date>2021-08-25T17:44:04Z</dc:date>
    </item>
    <item>
      <title>Re: Run multiple .sas file by changing \ to / on sas unix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-multiple-sas-file-by-changing-to-on-sas-unix/m-p/763941#M241947</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;did = filename(fref,'/data/Trials/ae.sas');
did = dopen(fref);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You try to use the DOPEN function, which is meant to open a&amp;nbsp;&lt;EM&gt;directory&lt;/EM&gt;, on a &lt;EM&gt;file&lt;/EM&gt;.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Aug 2021 18:15:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-multiple-sas-file-by-changing-to-on-sas-unix/m-p/763941#M241947</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-08-25T18:15:05Z</dc:date>
    </item>
    <item>
      <title>Re: Run multiple .sas file by changing \ to / on sas unix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-multiple-sas-file-by-changing-to-on-sas-unix/m-p/763954#M241953</link>
      <description>Sorry Kurt. I didn't quite catch you. I am trying everything and not a solution i am getting. It keep on says the directory doesn't exist. I am now exhausted!!!</description>
      <pubDate>Wed, 25 Aug 2021 18:45:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-multiple-sas-file-by-changing-to-on-sas-unix/m-p/763954#M241953</guid>
      <dc:creator>RAVI2000</dc:creator>
      <dc:date>2021-08-25T18:45:22Z</dc:date>
    </item>
    <item>
      <title>Re: Run multiple .sas file by changing \ to / on sas unix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-multiple-sas-file-by-changing-to-on-sas-unix/m-p/763956#M241954</link>
      <description>&lt;P&gt;Use the directory name, not the name of any individual file in the directory.&lt;/P&gt;
&lt;PRE&gt;1    filename xx '/unkown/directory';
2    data _null_;
3      did=dopen('xx');
4      put did=;
5      message=sysmsg();
6      put message=;
7      if did then did=dclose(did);
8    run;

did=0
message=ERROR: Physical file does not exist, /unkown/directory.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds

&lt;/PRE&gt;
&lt;P&gt;If the directory does not exist then it does not exist.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you sure the path you are using is the right path for the server where the SAS code is running?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Aug 2021 18:55:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-multiple-sas-file-by-changing-to-on-sas-unix/m-p/763956#M241954</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-08-25T18:55:05Z</dc:date>
    </item>
    <item>
      <title>Re: Run multiple .sas file by changing \ to / on sas unix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-multiple-sas-file-by-changing-to-on-sas-unix/m-p/763964#M241956</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;Sorry Kurt. I didn't quite catch you. I am trying everything and not a solution i am getting. It keep on says the directory doesn't exist. I am now exhausted!!!&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Something with a .sas extension is usually a SAS program (a text&amp;nbsp;&lt;EM&gt;file&lt;/EM&gt; containing SAS code), just like an object with a .csv extension is a data file (comma-separated text). Files can not be accessed with the DOPEN function, only directories.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Aug 2021 19:04:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-multiple-sas-file-by-changing-to-on-sas-unix/m-p/763964#M241956</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-08-25T19:04:15Z</dc:date>
    </item>
  </channel>
</rss>

