<?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: How to do a relative include? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-do-a-relative-include/m-p/23536#M3912</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It looks like your CURRENT macro is just creating a LIBREF and is not assigning anything to the CURRENT macro variable.&lt;/P&gt;&lt;P&gt;If it does assign a value to the CURRENT macro variable without first defining it as local then if you define it first the macro will be able to return a value.&amp;nbsp; (Look at the concept of LOCAL and GLOBAL macro variables).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So try:&lt;/P&gt;&lt;PRE __jive_macro_name="quote" class="jive_text_macro jive_macro_quote"&gt;&lt;P&gt;%let current=;&lt;/P&gt;&lt;P&gt;%current;&lt;/P&gt;&lt;P&gt;%put current="&amp;amp;current";&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;To see if that works.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another idea is just use . as the current directory.&amp;nbsp; This will reference whatever your SAS process considers the current working directory.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also you can use the PATHNAME function to get the path to the CURRENT library that the macro is creating.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __jive_macro_name="quote" class="jive_text_macro jive_macro_quote"&gt;&lt;P&gt;%current;&lt;/P&gt;&lt;P&gt;%let current=%sysfunc(pathname(current));&lt;/P&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 04 Oct 2011 19:18:07 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2011-10-04T19:18:07Z</dc:date>
    <item>
      <title>How to do a relative include?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-do-a-relative-include/m-p/23528#M3904</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a number of directories each containing the same sas program.&amp;nbsp; I would like to&lt;/P&gt;&lt;P&gt;set some macro variables in a small sas file in each of these directories and then&lt;/P&gt;&lt;P&gt;include it in the main sas program.&amp;nbsp; Because the main sas program can be copied&lt;/P&gt;&lt;P&gt;to a number of directories I don't want to use an absolute path in the include statement.&lt;/P&gt;&lt;P&gt;Is there a way to use relative paths?&amp;nbsp;&amp;nbsp; For example, if I had this include statement in&lt;/P&gt;&lt;P&gt;my main sas program:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%include 'linemg.sas';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and then tried to run the main sas program from within the sas application window, I get&lt;/P&gt;&lt;P&gt;an error stating that it cannot open the file.&amp;nbsp; If I specify the absolute path in the include&lt;/P&gt;&lt;P&gt;statement it works but I don't want to have to do that.&amp;nbsp; Does the concept of a current working&lt;/P&gt;&lt;P&gt;directory exist in sas?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Oct 2011 14:38:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-do-a-relative-include/m-p/23528#M3904</guid>
      <dc:creator>WesBarris</dc:creator>
      <dc:date>2011-10-04T14:38:01Z</dc:date>
    </item>
    <item>
      <title>How to do a relative include?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-do-a-relative-include/m-p/23529#M3905</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There is a 'current folder'. Set or change it with SAS statement:&lt;/P&gt;&lt;P&gt;X CD "your preferred folder";&lt;/P&gt;&lt;P&gt;The default is set by the current folder in which SAS is launched. &lt;/P&gt;&lt;P&gt;Relative folders can be defined in the normal way&lt;/P&gt;&lt;P&gt;Here is&amp;nbsp; ./&lt;/P&gt;&lt;P&gt;Parent ../&lt;/P&gt;&lt;P&gt;Child folder ./childfolder&lt;/P&gt;&lt;P&gt;Cousin folder ../cousin&lt;/P&gt;&lt;P&gt;Use \ if not on unix (only sometimes do we get away with / on windows)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Peter&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Oct 2011 15:10:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-do-a-relative-include/m-p/23529#M3905</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2011-10-04T15:10:53Z</dc:date>
    </item>
    <item>
      <title>How to do a relative include?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-do-a-relative-include/m-p/23530#M3906</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Take a look at the various options expressed throughout the following sas-l thread:&lt;/P&gt;&lt;P&gt;&lt;A href="http://listserv.uga.edu/cgi-bin/wa?A2=ind1010a&amp;amp;L=sas-l&amp;amp;D=0&amp;amp;O=D&amp;amp;m=22408&amp;amp;P=13821"&gt;http://listserv.uga.edu/cgi-bin/wa?A2=ind1010a&amp;amp;L=sas-l&amp;amp;D=0&amp;amp;O=D&amp;amp;m=22408&amp;amp;P=13821&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Oct 2011 15:12:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-do-a-relative-include/m-p/23530#M3906</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2011-10-04T15:12:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to do a relative include?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-do-a-relative-include/m-p/23531#M3907</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Art,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is exactly what I was looking for.&amp;nbsp; However, I can't seem to get it to work.&amp;nbsp; I tried this piece of code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;* ConCheck.sas ;&lt;/P&gt;&lt;P&gt;%include 'c:\SASUtils\dissectionIO20110912.sas';&lt;/P&gt;&lt;P&gt;%include 'c:\SASUtils\Current.sas';&lt;/P&gt;&lt;P&gt;%Current;&lt;/P&gt;&lt;P&gt;%include "&amp;amp;Current\linemg.sas"';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The output log shows this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp; * ConCheck.sas ;&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp; %include 'c:\SASUtils\dissectionIO20110912.sas';&lt;/P&gt;&lt;P&gt;22&amp;nbsp;&amp;nbsp; %include 'c:\SASUtils\Current.sas';&lt;/P&gt;&lt;P&gt;38&amp;nbsp;&amp;nbsp; %Current;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NOTE: The infile PRESENT is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Unnamed Pipe Access Device,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PROCESS=CD,RECFM=V,LRECL=256&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Stderr output:&lt;/P&gt;&lt;P&gt;The handle is invalid.&lt;/P&gt;&lt;P&gt;NOTE: 0 records were read from the infile PRESENT.&lt;/P&gt;&lt;P&gt;NOTE: DATA statement used (Total process time):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; real time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.14 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cpu time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.03 seconds&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NOTE: Libref CURRENT was successfully assigned as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Engine:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; V9&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Physical Name: C:\Users\barrisw\&lt;/P&gt;&lt;P&gt;39&amp;nbsp;&amp;nbsp; %include "&amp;amp;Current\linemg.sas";&lt;/P&gt;&lt;P&gt;WARNING: Physical file does not exist, C:\linemg.sas.&lt;/P&gt;&lt;P&gt;ERROR: Cannot open %INCLUDE file \linemg.sas.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Oct 2011 15:51:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-do-a-relative-include/m-p/23531#M3907</guid>
      <dc:creator>WesBarris</dc:creator>
      <dc:date>2011-10-04T15:51:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to do a relative include?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-do-a-relative-include/m-p/23532#M3908</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is a workaround. Assuming all of your directories which contains SAS code are under c:\temp.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;filename fname pipe 'dir c:\temp\*.sas /S /b';
data _null_;
infile fname;
input;
call symputx(scan(_infile_,-2,'.\'),_infile_);
run;
%put _user_;
%include "&amp;amp;a1";










86&amp;nbsp;&amp;nbsp; %put _user_;
GLOBAL A1 c:\temp\a\a1.sas
GLOBAL A2 c:\temp\a\a2.sas
GLOBAL B1 c:\temp\b\b1.sas
GLOBAL B2 c:\temp\b\b2.sas
87&amp;nbsp;&amp;nbsp; %include "&amp;amp;a1";

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;消息编辑者为：xia keshan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Oct 2011 18:16:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-do-a-relative-include/m-p/23532#M3908</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-10-04T18:16:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to do a relative include?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-do-a-relative-include/m-p/23533#M3909</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Wes, Do you happen to have the name(s) current and/or present reserved for something else?&amp;nbsp; It worked perfectly on my machine.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You shouldn't end the macro call with a semi-colon, but that wouldn't cause the error you received.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Oct 2011 18:35:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-do-a-relative-include/m-p/23533#M3909</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2011-10-04T18:35:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to do a relative include?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-do-a-relative-include/m-p/23534#M3910</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Art,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't think that Current or Present are defined anywhere else.&amp;nbsp; I've found that if I navigate inside Windows Explorer to the sas file and double-click on it, it opens the SAS environment window.&amp;nbsp; If I then click on the "run" icon it works.&amp;nbsp; However, if I first start the SAS environment and then use File-&amp;gt; Open Program and then navigate to that same sas file, and then run it, it issues the errors I mentioned.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Successful run (double clicking on sas file in windows explorer):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp; * ConCheck.sas ;&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp; %include 'c:\SASUtils\dissectionIO20110912.sas';&lt;/P&gt;&lt;P&gt;22&amp;nbsp;&amp;nbsp; %include 'c:\SASUtils\Current.sas';&lt;/P&gt;&lt;P&gt;38&amp;nbsp;&amp;nbsp; %Current;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NOTE: The infile PRESENT is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Unnamed Pipe Access Device,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PROCESS=CD,RECFM=V,LRECL=256&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NOTE: 1 record was read from the infile PRESENT.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The minimum record length was 11.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The maximum record length was 11.&lt;/P&gt;&lt;P&gt;NOTE: DATA statement used (Total process time):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; real time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.03 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cpu time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.00 seconds&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NOTE: Libref CURRENT was successfully assigned as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Engine:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; V9&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Physical Name: M:\L01mg300&lt;/P&gt;&lt;P&gt;39&amp;nbsp;&amp;nbsp; %include "&amp;amp;Current\linemg.sas";&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Failed run (navigating to file from sas environment):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp; * ConCheck.sas ;&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp; %include 'c:\SASUtils\dissectionIO20110912.sas';&lt;/P&gt;&lt;P&gt;22&amp;nbsp;&amp;nbsp; %include 'c:\SASUtils\Current.sas';&lt;/P&gt;&lt;P&gt;38&amp;nbsp;&amp;nbsp; %Current;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NOTE: The infile PRESENT is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Unnamed Pipe Access Device,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PROCESS=CD,RECFM=V,LRECL=256&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Stderr output:&lt;/P&gt;&lt;P&gt;The handle is invalid.&lt;/P&gt;&lt;P&gt;NOTE: 0 records were read from the infile PRESENT.&lt;/P&gt;&lt;P&gt;NOTE: DATA statement used (Total process time):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; real time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.03 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cpu time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.00 seconds&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NOTE: Libref CURRENT was successfully assigned as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Engine:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; V9&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Physical Name: C:\Users\barrisw\&lt;/P&gt;&lt;P&gt;39&amp;nbsp;&amp;nbsp; %include "&amp;amp;Current\linemg.sas";&lt;/P&gt;&lt;P&gt;WARNING: Physical file does not exist, C:\linemg.sas.&lt;/P&gt;&lt;P&gt;ERROR: Cannot open %INCLUDE file \linemg.sas.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Oct 2011 18:49:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-do-a-relative-include/m-p/23534#M3910</guid>
      <dc:creator>WesBarris</dc:creator>
      <dc:date>2011-10-04T18:49:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to do a relative include?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-do-a-relative-include/m-p/23535#M3911</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ksharp,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the advice.&amp;nbsp; However, when I tried to run this I got errors.&amp;nbsp; Perhaps I'm not doing this correctly:&lt;/P&gt;&lt;P&gt;Plus, I dont' want to have to specify the directory in the sas program.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;filename fname pipe 'dir m:\L01mg300\*.sas /S /b';&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;infile fname;&lt;/P&gt;&lt;P&gt;input;&lt;/P&gt;&lt;P&gt;call symputx(scan(_infile_,-2,'.\'),_infile_);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%put _user_;&lt;/P&gt;&lt;P&gt;%include "&amp;amp;a1";&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Log output:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NOTE: Copyright (c) 2002-2008 by SAS Institute Inc., Cary, NC, USA.&lt;/P&gt;&lt;P&gt;NOTE: SAS (r) Proprietary Software 9.2 (TS2M3)&lt;/P&gt;&lt;P&gt;NOTE: This session is executing on the X64_DSRV08&amp;nbsp; platform.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NOTE: SAS initialization used:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; real time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1.96 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cpu time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.79 seconds&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp; filename fname pipe 'dir m:\L01mg300\*.sas /S /b';&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp; data _null_;&lt;/P&gt;&lt;P&gt;3&amp;nbsp;&amp;nbsp;&amp;nbsp; infile fname;&lt;/P&gt;&lt;P&gt;4&amp;nbsp;&amp;nbsp;&amp;nbsp; input;&lt;/P&gt;&lt;P&gt;5&amp;nbsp;&amp;nbsp;&amp;nbsp; call symputx(scan(_infile_,-2,'.\'),_infile_);&lt;/P&gt;&lt;P&gt;6&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NOTE: The infile FNAME is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Unnamed Pipe Access Device,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PROCESS=dir m:\L01mg300\*.sas /S /b,RECFM=V,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LRECL=256&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Stderr output:&lt;/P&gt;&lt;P&gt;There is not enough space on the disk.&lt;/P&gt;&lt;P&gt;NOTE: 0 records were read from the infile FNAME.&lt;/P&gt;&lt;P&gt;NOTE: DATA statement used (Total process time):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; real time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.15 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cpu time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.03 seconds&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;7&amp;nbsp;&amp;nbsp;&amp;nbsp; %put _user_;&lt;/P&gt;&lt;P&gt;8&amp;nbsp;&amp;nbsp;&amp;nbsp; %include "&amp;amp;a1";&lt;/P&gt;&lt;P&gt;WARNING: Apparent symbolic reference A1 not resolved.&lt;/P&gt;&lt;P&gt;WARNING: Physical file does not exist, C:\Users\barrisw\&amp;amp;a1.&lt;/P&gt;&lt;P&gt;ERROR: Cannot open %INCLUDE file &amp;amp;a1.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Oct 2011 18:56:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-do-a-relative-include/m-p/23535#M3911</guid>
      <dc:creator>WesBarris</dc:creator>
      <dc:date>2011-10-04T18:56:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to do a relative include?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-do-a-relative-include/m-p/23536#M3912</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It looks like your CURRENT macro is just creating a LIBREF and is not assigning anything to the CURRENT macro variable.&lt;/P&gt;&lt;P&gt;If it does assign a value to the CURRENT macro variable without first defining it as local then if you define it first the macro will be able to return a value.&amp;nbsp; (Look at the concept of LOCAL and GLOBAL macro variables).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So try:&lt;/P&gt;&lt;PRE __jive_macro_name="quote" class="jive_text_macro jive_macro_quote"&gt;&lt;P&gt;%let current=;&lt;/P&gt;&lt;P&gt;%current;&lt;/P&gt;&lt;P&gt;%put current="&amp;amp;current";&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;To see if that works.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another idea is just use . as the current directory.&amp;nbsp; This will reference whatever your SAS process considers the current working directory.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also you can use the PATHNAME function to get the path to the CURRENT library that the macro is creating.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __jive_macro_name="quote" class="jive_text_macro jive_macro_quote"&gt;&lt;P&gt;%current;&lt;/P&gt;&lt;P&gt;%let current=%sysfunc(pathname(current));&lt;/P&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Oct 2011 19:18:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-do-a-relative-include/m-p/23536#M3912</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2011-10-04T19:18:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to do a relative include?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-do-a-relative-include/m-p/23537#M3913</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Tom.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Attempting your first suggestion:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1774&amp;nbsp; %let Current=;&lt;/P&gt;&lt;P&gt;1775&amp;nbsp; %Current;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NOTE: The infile PRESENT is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Unnamed Pipe Access Device,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PROCESS=CD,RECFM=V,LRECL=256&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Stderr output:&lt;/P&gt;&lt;P&gt;The handle is invalid.&lt;/P&gt;&lt;P&gt;NOTE: 0 records were read from the infile PRESENT.&lt;/P&gt;&lt;P&gt;NOTE: DATA statement used (Total process time):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; real time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.03 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cpu time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.01 seconds&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NOTE: Libref CURRENT was successfully assigned as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Engine:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; V9&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Physical Name: C:\Users\barrisw\&lt;/P&gt;&lt;P&gt;1776&amp;nbsp; %put Current="&amp;amp;Current";&lt;/P&gt;&lt;P&gt;Current=""&lt;/P&gt;&lt;P&gt;1777&amp;nbsp; %include "&amp;amp;Current\linemg.sas";&lt;/P&gt;&lt;P&gt;WARNING: Physical file does not exist, C:\linemg.sas.&lt;/P&gt;&lt;P&gt;ERROR: Cannot open %INCLUDE file \linemg.sas.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've already tried usine ./linemg.sas but the current working directory inside the SAS environment is not the same as where the .sas file sits in the filesystem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;using sysfunc and pathname...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;looks like it is picking up my home directory and not the directory where the .sas program exists.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NOTE: Libref CURRENT was successfully assigned as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Engine:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; V9&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Physical Name: C:\Users\barrisw&lt;/P&gt;&lt;P&gt;1341&amp;nbsp; %let Current=%sysfunc(pathname(Current));&lt;/P&gt;&lt;P&gt;1342&amp;nbsp; %include "&amp;amp;Current\linemg.sas";&lt;/P&gt;&lt;P&gt;WARNING: Physical file does not exist, C:\Users\barrisw\linemg.sas.&lt;/P&gt;&lt;P&gt;ERROR: Cannot open %INCLUDE file C:\Users\barrisw\linemg.sas.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Oct 2011 19:32:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-do-a-relative-include/m-p/23537#M3913</guid>
      <dc:creator>WesBarris</dc:creator>
      <dc:date>2011-10-04T19:32:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to do a relative include?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-do-a-relative-include/m-p/23538#M3914</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If the relative path you need is relative to the location of the currently executing SAS program I think you are looking for the automatic SAS variables SAS_EXECFILEPATH and SAS_EXECFILENAME.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This requires the executing code to have been saved. The macro variable PATH should be &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let a=%sysget(SAS_EXECFILEPATH);&lt;BR /&gt;%let b=%sysget(SAS_EXECFILENAME);&lt;/P&gt;&lt;P&gt;%let path= %sysfunc(tranwrd(&amp;amp;a,&amp;amp;b,''));&lt;BR /&gt;%put &amp;amp;path;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The macro variable PATH should be ready to use as %include "&amp;amp;path.codefile.sas";&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Oct 2011 22:47:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-do-a-relative-include/m-p/23538#M3914</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2011-10-04T22:47:11Z</dc:date>
    </item>
    <item>
      <title>How to do a relative include?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-do-a-relative-include/m-p/23539#M3915</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Wes&lt;/P&gt;&lt;P&gt;looks like you need to set the current folder, then relative paths will work from there. Double click on the folder/address in the status-bar aat the foot of the SAS environment (assuming that you are not running sas in enterprise guide)&lt;/P&gt;&lt;P&gt;&lt;IMG alt="status.bar.JPG" class="jive-image-thumbnail jive-image" onclick="" src="https://communities.sas.com/legacyfs/online/1203_status.bar.JPG" width="450" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or&amp;nbsp; submit statement&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; x cd 'required current folder' ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Peter.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Oct 2011 16:22:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-do-a-relative-include/m-p/23539#M3915</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2011-10-05T16:22:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to do a relative include?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-do-a-relative-include/m-p/23540#M3916</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;IF you are using the "enhanced" editor in Windows then you can take advantage of environment variables that it sets. That's a big IF for those of us using SAS on other operating systems or who just prefer the normal program editor.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I prefer to use SUBSTR and LENGTH to deal with pulling just the path from the beginning of a string.&amp;nbsp; Using a translate function runs the risk of confusion if some friendly programmer happended to have created a subdirectory that matches your filename.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __jive_macro_name="quote" class="jive_text_macro jive_macro_quote"&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data _null_;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; p1=sysget('sas_execfilepath');&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; p2=sysget('sas_execfilename');&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; dir=substr(p1||' ',1,length(p1)-length(p2));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; call system('cd ' || quote(trim(dir)));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; put 'Running program: ' p1 / 'Switching to directory: ' dir ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Oct 2011 18:31:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-do-a-relative-include/m-p/23540#M3916</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2011-10-05T18:31:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to do a relative include?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-do-a-relative-include/m-p/23541#M3917</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks ballardw, that is exactly what I was looking for.&amp;nbsp; I only had to make one small modification to get it working.&amp;nbsp; That was to remove the empty quotes:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let path= %sysfunc(tranwrd(&amp;amp;a,&amp;amp;b,));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;tranwrd was replacing the filename with the two adjacent quotes.&amp;nbsp; Removing them made it do what I needed.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Oct 2011 21:16:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-do-a-relative-include/m-p/23541#M3917</guid>
      <dc:creator>WesBarris</dc:creator>
      <dc:date>2011-10-05T21:16:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to do a relative include?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-do-a-relative-include/m-p/23542#M3918</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Tom.&amp;nbsp; That is a good point about the lenght and substring.&amp;nbsp; I'll probably implement something like that.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Oct 2011 21:17:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-do-a-relative-include/m-p/23542#M3918</guid>
      <dc:creator>WesBarris</dc:creator>
      <dc:date>2011-10-05T21:17:45Z</dc:date>
    </item>
  </channel>
</rss>

