<?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 set _SASPROGRAMFILE using EG Automation in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-set-SASPROGRAMFILE-using-EG-Automation/m-p/384786#M24783</link>
    <description>&lt;P&gt;Why not prepend your&amp;nbsp;&lt;STRONG&gt;fileString&lt;/STRONG&gt; variable with the path you want, parsing it from sasPgmFile (or using FileSystemObject methods to get it for you)? &amp;nbsp;Add a "%LET" statement with that value, then add on the remainder of the program that you read from the file?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That puts your VBScript in control of how that value gets set.&lt;/P&gt;</description>
    <pubDate>Tue, 01 Aug 2017 20:13:41 GMT</pubDate>
    <dc:creator>ChrisHemedinger</dc:creator>
    <dc:date>2017-08-01T20:13:41Z</dc:date>
    <item>
      <title>How to set _SASPROGRAMFILE using EG Automation</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-set-SASPROGRAMFILE-using-EG-Automation/m-p/384776#M24782</link>
      <description>&lt;P&gt;Hi, I'm using EG automation via a VBScript to batch submit SAS programs from a thrid party editor. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Interactively, SAS EG will set the _SASPROGRAMFILE macro variable to be the fully qualified path and file name of the SAS program running, but EG automation does not set this. &amp;nbsp;I'm using EG 7.13 HF4 and SAS 9.4.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My VBScript, via file system and file streaming objects, reads in the text from the SAS program, assigns to the Code.Text property and runs. &amp;nbsp;See below. &amp;nbsp;It all works fine except I cannot assign librefs, etc. using part of the program path without hard-coding the path in the text of the batch submitted program.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;MM&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dim fileSys, fReadStream, fileString&lt;BR /&gt;Set fileSys = CreateObject("Scripting.FileSystemObject")&lt;BR /&gt;Set fReadStream = fileSys.OpenTextFile(sasPgmFile, 1, False)&lt;BR /&gt;fileString = fReadStream.ReadAll()&lt;/P&gt;&lt;P&gt;' add the new code object to the project&lt;BR /&gt;Set sasPgmObj = EGPrjObj.CodeCollection.Add&lt;BR /&gt;&lt;BR /&gt;' set the results types, overriding Application defaults&lt;BR /&gt;sasPgmObj.UseApplicationOptions = False&lt;BR /&gt;sasPgmObj.GenListing = True&lt;BR /&gt;sasPgmObj.GenSasReport = False&lt;/P&gt;&lt;P&gt;' Set the server and text for the code&lt;BR /&gt;sasPgmObj.Server = sasServer&lt;BR /&gt;sasPgmObj.Text = fileString&lt;BR /&gt;sasPgmObj.Run ' Run the code&lt;/P&gt;</description>
      <pubDate>Tue, 01 Aug 2017 19:47:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-set-SASPROGRAMFILE-using-EG-Automation/m-p/384776#M24782</guid>
      <dc:creator>mm4kite</dc:creator>
      <dc:date>2017-08-01T19:47:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to set _SASPROGRAMFILE using EG Automation</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-set-SASPROGRAMFILE-using-EG-Automation/m-p/384786#M24783</link>
      <description>&lt;P&gt;Why not prepend your&amp;nbsp;&lt;STRONG&gt;fileString&lt;/STRONG&gt; variable with the path you want, parsing it from sasPgmFile (or using FileSystemObject methods to get it for you)? &amp;nbsp;Add a "%LET" statement with that value, then add on the remainder of the program that you read from the file?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That puts your VBScript in control of how that value gets set.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Aug 2017 20:13:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-set-SASPROGRAMFILE-using-EG-Automation/m-p/384786#M24783</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2017-08-01T20:13:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to set _SASPROGRAMFILE using EG Automation</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-set-SASPROGRAMFILE-using-EG-Automation/m-p/384822#M24789</link>
      <description>&lt;P&gt;Thanks Chris, that's a good thought. &amp;nbsp;We are trying to process this information prior to the program execution on the SASApp server. &amp;nbsp; However, I'll look into this to see if it is a viable option.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I take it, there's not a way to set a property or something on the EG App or Project Object to tell SAS to set a specific macro then as the SASApp server boots and runs any configuration or autoexec commands?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;MM&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Aug 2017 22:00:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-set-SASPROGRAMFILE-using-EG-Automation/m-p/384822#M24789</guid>
      <dc:creator>mm4kite</dc:creator>
      <dc:date>2017-08-01T22:00:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to set _SASPROGRAMFILE using EG Automation</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-set-SASPROGRAMFILE-using-EG-Automation/m-p/384828#M24791</link>
      <description>&lt;P&gt;You could create/run&amp;nbsp;&lt;STRONG&gt;another&lt;/STRONG&gt; Code item before doing anything else, and stuff it full of all of the %LET statements that you want...&lt;/P&gt;</description>
      <pubDate>Tue, 01 Aug 2017 22:25:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-set-SASPROGRAMFILE-using-EG-Automation/m-p/384828#M24791</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2017-08-01T22:25:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to set _SASPROGRAMFILE using EG Automation</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-set-SASPROGRAMFILE-using-EG-Automation/m-p/385143#M24807</link>
      <description>&lt;P&gt;Hi Chris,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After researching inserting "%global &amp;lt;macrovar&amp;gt;; %let &amp;lt;macrovar&amp;gt;=&amp;lt;saspgmpath&amp;gt;;" to the front of the file stream, I believe this solution will work by updating another program. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;</description>
      <pubDate>Wed, 02 Aug 2017 22:40:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-set-SASPROGRAMFILE-using-EG-Automation/m-p/385143#M24807</guid>
      <dc:creator>mm4kite</dc:creator>
      <dc:date>2017-08-02T22:40:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to set _SASPROGRAMFILE using EG Automation</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-set-SASPROGRAMFILE-using-EG-Automation/m-p/385161#M24809</link>
      <description>&lt;P&gt;Mark,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm glad Chris'&amp;nbsp;solution will work for you.&amp;nbsp; I agree, that sounds like the best route to take.&amp;nbsp; However, I wanted to provide a little more information for clarity...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The "EGPrjObj.CodeCollection.Add"&amp;nbsp;call in your example adds a new program to the EG project (equivalent to interactive File-&amp;gt;New-&amp;gt;Program).&amp;nbsp; The key here is that this new program is embedded (stored in the EG project (.egp file))&amp;nbsp;by default, rather than a&amp;nbsp;shortcut to a .sas file on disk.&amp;nbsp; This is important because the _SASPROGRAMFILE macro value is empty (two single quotes) for embedded programs, since there is no physical program file to reference.&amp;nbsp; For example, you'll see this near the top of the log:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%LET _SASPROGRAMFILE='';&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, EG &lt;EM&gt;is&lt;/EM&gt; generating the code that sets the _SASPROGRAMFILE macro in this case (both interactively and via automation), it just happens to be set to empty, since it is an embedded program (there is no program file).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you add an existing .sas file to an EG project (ex. File-&amp;gt;Open-&amp;gt;Program, interactively), the _SASPROGRAMFILE macro will contain the path to the .sas file (when run interactively or via automation).&amp;nbsp; The root problem is there does not appear to be a way to add an existing .sas program (reference/shortcut)&amp;nbsp;to an EG project via automation.&amp;nbsp; I did not find an API in the current automation interface for doing this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope that helps.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Casey&lt;/P&gt;</description>
      <pubDate>Thu, 03 Aug 2017 02:13:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-set-SASPROGRAMFILE-using-EG-Automation/m-p/385161#M24809</guid>
      <dc:creator>CaseySmith</dc:creator>
      <dc:date>2017-08-03T02:13:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to set _SASPROGRAMFILE using EG Automation</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-set-SASPROGRAMFILE-using-EG-Automation/m-p/386132#M24885</link>
      <description>&lt;P&gt;Hi Casey,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the additional information.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-Mark&lt;/P&gt;</description>
      <pubDate>Mon, 07 Aug 2017 20:12:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-set-SASPROGRAMFILE-using-EG-Automation/m-p/386132#M24885</guid>
      <dc:creator>mm4kite</dc:creator>
      <dc:date>2017-08-07T20:12:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to set _SASPROGRAMFILE using EG Automation</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-set-SASPROGRAMFILE-using-EG-Automation/m-p/547036#M33323</link>
      <description>&lt;P&gt;Hi &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15089"&gt;@CaseySmith&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've been learning the automation interface for about the last week or two.&amp;nbsp; Got a powershell script that queries an Excel file and passes parameters into SAS filter prompts.&amp;nbsp; Everything is working, but I am wondering about reusability of the code.&amp;nbsp; Every time the script is run, a new code node will be added.&amp;nbsp; Did you ever figure out a way to call an existing program or a way to clean the node up once the code runs?&lt;/P&gt;</description>
      <pubDate>Thu, 28 Mar 2019 21:02:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-set-SASPROGRAMFILE-using-EG-Automation/m-p/547036#M33323</guid>
      <dc:creator>jbbell</dc:creator>
      <dc:date>2019-03-28T21:02:54Z</dc:date>
    </item>
  </channel>
</rss>

