<?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: Use of %include and file path in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Use-of-include-and-file-path/m-p/818031#M322882</link>
    <description>&lt;P&gt;&lt;SPAN&gt;Automatic macro variables can be used to solve it.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;sysincludefiledir&lt;/P&gt;
&lt;P&gt;sysincludefilename&lt;/P&gt;
&lt;P&gt;sysincludefiledevice&lt;/P&gt;
&lt;P&gt;sysinculdefileref&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 14 Jun 2022 09:39:26 GMT</pubDate>
    <dc:creator>whymath</dc:creator>
    <dc:date>2022-06-14T09:39:26Z</dc:date>
    <item>
      <title>Use of %include and file path</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-of-include-and-file-path/m-p/548292#M152026</link>
      <description>&lt;P&gt;I have 2 sas programs:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. D:\SAS\main.sas&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%include "run.sas";&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. D:\SAS\run.sas&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let outputfile = %qsubstr(%sysget(SAS_EXECFILEPATH),1, %length(%sysget(SAS_EXECFILEPATH))-4) ;
dm 'log; file "&amp;amp;outputfile..log" replace ';
dm 'log; clear';&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I run the run.sas separately without using %include, I can create run.log file. But if I call run.sas using main.sas then I get main.log instead.&lt;BR /&gt;I need to call run.sas from main.sas using %include and need to create run.log.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Apr 2019 21:02:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-of-include-and-file-path/m-p/548292#M152026</guid>
      <dc:creator>bhu</dc:creator>
      <dc:date>2019-04-03T21:02:25Z</dc:date>
    </item>
    <item>
      <title>Re: Use of %include and file path</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-of-include-and-file-path/m-p/548302#M152031</link>
      <description>&lt;P&gt;&lt;SPAN&gt;What happens if you try to overwrite the value of that environment variable in main.sas?&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options set=SAS_EXECFILEPATH "run.sas";
%include "run.sas";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;Note that your code is not very portable.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your code is using Display Manager commands, so it can never be run like a normal SAS program, only from an interactive session that is using Display Manager.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your code is referencing&amp;nbsp;&lt;SPAN&gt;SAS_EXECFILEPATH which is an environment variable set by the&amp;nbsp; Enhanced Editor on the PC implementation of SAS Display Manager.&amp;nbsp; So even if you were running on SAS Display Manger, but you were using the regular program editor instead (only editor available on Unix versions of SAS) or using Notepad editor then it wouldn't work.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Apr 2019 18:53:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-of-include-and-file-path/m-p/548302#M152031</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-04-03T18:53:49Z</dc:date>
    </item>
    <item>
      <title>Re: Use of %include and file path</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-of-include-and-file-path/m-p/548314#M152034</link>
      <description>&lt;P&gt;A simpler design might be to make the current directory where you want the logs to go.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;* main program ;
x "cd path";
%include "run.sas";

* run.sas ;
dm 'log; file "run.log" replace ';
dm 'log; clear';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You could try to figure out what directory to change to based on the value of SAS_EXECFILEPATH.&amp;nbsp; But watch out for paths that are on a different mapped drive letter.&amp;nbsp; Or are using UNCs (\\servername\sharename\....).&lt;/P&gt;</description>
      <pubDate>Wed, 03 Apr 2019 19:16:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-of-include-and-file-path/m-p/548314#M152034</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-04-03T19:16:33Z</dc:date>
    </item>
    <item>
      <title>Re: Use of %include and file path</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-of-include-and-file-path/m-p/548344#M152039</link>
      <description>&lt;P&gt;HI Tom, thank you so much for your reply. Both of your methods need a line to be added before %include. Here I will run a series of run.sas, like&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%include "run1.sas";
%include "runA.sas";
%include "run2.sas";
%include "run45.sas";&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, I need a dynamic variable which can capture the file name which is being called not file name that is calling it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And, yes I am using SAS 9.4 editor in which "dm" is supported. I would like to know the alternative of dm if I need to run it other than Display Manager.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Apr 2019 21:16:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-of-include-and-file-path/m-p/548344#M152039</guid>
      <dc:creator>bhu</dc:creator>
      <dc:date>2019-04-03T21:16:36Z</dc:date>
    </item>
    <item>
      <title>Re: Use of %include and file path</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-of-include-and-file-path/m-p/548394#M152061</link>
      <description>&lt;P&gt;If you need to keep logs of the code you run you should be running the programs from the command line instead running in interactive SAS. THen the log will have ALL of the SAS session and avoid issues with code running differently because of left over effects from previous code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Open a command window and move to the folder where the programs are saved.&lt;/P&gt;
&lt;P&gt;At the command line type the command SAS followed by the name of the program you want to run.&amp;nbsp; You could group a bunch of commands together into a .BAT file.&lt;/P&gt;
&lt;PRE&gt;sas "run1.sas"
sas "runA.sas"
sas "run2.sas"
sas "run45.sas"&lt;/PRE&gt;
&lt;P&gt;If your search path in windows does not know how to find the SAS command then either add the directory to the search path or use the fully qualified name of the SAS executable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Apr 2019 03:56:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-of-include-and-file-path/m-p/548394#M152061</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-04-04T03:56:48Z</dc:date>
    </item>
    <item>
      <title>Re: Use of %include and file path</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-of-include-and-file-path/m-p/818031#M322882</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Automatic macro variables can be used to solve it.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;sysincludefiledir&lt;/P&gt;
&lt;P&gt;sysincludefilename&lt;/P&gt;
&lt;P&gt;sysincludefiledevice&lt;/P&gt;
&lt;P&gt;sysinculdefileref&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jun 2022 09:39:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-of-include-and-file-path/m-p/818031#M322882</guid>
      <dc:creator>whymath</dc:creator>
      <dc:date>2022-06-14T09:39:26Z</dc:date>
    </item>
  </channel>
</rss>

