<?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: Pass a Parameter from Excel VBA to a SAS EG project. in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Pass-a-Parameter-from-Excel-VBA-to-a-SAS-EG-project/m-p/344854#M22827</link>
    <description>&lt;P&gt;Hi &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/133867"&gt;@CalebSturges&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It looks like you are really close...&amp;nbsp; I&amp;nbsp;attempted&amp;nbsp;using EG 5.1 (32-bit w/ HF21) and Excel 2013 (32-bit)&amp;nbsp;and your code works for me with one change...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I commented out this line, since retrieving the DefaultValue property was causing an error, presumably since I didn't specify a default value for the prompt I defined:&lt;/P&gt;
&lt;PRE&gt;'Retrieving parm.DefaultValue causes error because no default value was set
'on the prompt I defined
'MsgBox parm.Name &amp;amp; " parameter has default value of " &amp;amp; parm.DefaultValue
MsgBox parm.Name &amp;amp; " parameter"&lt;/PRE&gt;
&lt;P&gt;In EG's View-&amp;gt;Prompt Manager, make sure you have at least one prompt defined.&amp;nbsp; For example, I accepted the defaults, which created a text prompt named "Prompt_1".&amp;nbsp; Then, I created a program in EG with this code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%put "&amp;amp;Prompt_1";
proc print data=sashelp.class;
where sex eq "&amp;amp;Prompt_1";
run;&lt;/PRE&gt;
&lt;P&gt;Then, make sure you associate the prompt with the program by clicking Properties on the program, Prompts page, then add the prompt you want to use with that program.&amp;nbsp; Run the program/project in EG&amp;nbsp;to make sure you get prompted and runs as expected.&amp;nbsp; If so,&amp;nbsp;delete the SAS results output (so you can easily tell if the project was re-run...&amp;nbsp; results recreated), save the project and close EG.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now when I run the VBA code, the value I specify ("M" or "F") is properly passed into the EG project and used in the code for me.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Casey&lt;/P&gt;</description>
    <pubDate>Tue, 28 Mar 2017 02:55:50 GMT</pubDate>
    <dc:creator>CaseySmith</dc:creator>
    <dc:date>2017-03-28T02:55:50Z</dc:date>
    <item>
      <title>Pass a Parameter from Excel VBA to a SAS EG project.</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Pass-a-Parameter-from-Excel-VBA-to-a-SAS-EG-project/m-p/344822#M22824</link>
      <description>&lt;P&gt;I'm having trouble passing a parameter through Excel VBA to my SAS Enterprise Guide project. My problem is basically the same as this user's &lt;A href="https://communities.sas.com/t5/SAS-Enterprise-Guide/pass-a-parameter-to-SAS-EG-project/td-p/75742" target="_self"&gt;problem&lt;/A&gt;, but I tried all the proposed solutions and none worked (it was in 2009 and&amp;nbsp;the technology is all different. I'm using Enterprise guide 5.1 and Excel VBA 2010 on Windows 7. He was using enterprise guide 4 and visual basic scripts.) &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Option Explicit&lt;BR /&gt;Public ApplicationObj 'Application&lt;BR /&gt;Public Proj 'Project object&lt;BR /&gt;Public sasProgram 'Code object (SAS program)&lt;BR /&gt;Public log1 As String&lt;BR /&gt;Public parmList&lt;BR /&gt;Public parm&lt;BR /&gt;&lt;BR /&gt;Sub RunSAS()
On Error GoTo ErrHandler
Set ApplicationObj = CreateObject("SASEGObjectModel.Application.5.1")
Set Proj = ApplicationObj.Open("C:\Users\sturgec\Documents\PD0TO11completeupdRIDErecalib.egp", "")
Set parmList = Proj.Parameters
MsgBox "Project has " &amp;amp; parmList.Count &amp;amp; " parameters."
Set parm = parmList.item(0)
MsgBox parm.Name &amp;amp; " parameter has default value of " &amp;amp; parm.DefaultValue
parm.Value = "M"

MsgBox parm.Name &amp;amp; " parameter has been set to value of " &amp;amp; parm.Value
Proj.Run

Proj.SaveAs "C:\Users\sturgec\Documents\NewPD0TO11completeupdRIDErecalib.egp"
Proj.Close
ApplicationObj.Quit
End Sub&lt;/PRE&gt;&lt;P&gt;The main solution, as shown above was to set some default value "Paramters", but when I tried to access it says: "Project has 0 parameters" and then in the line:&lt;/P&gt;&lt;PRE&gt;Set parm = parmList.item(0)&lt;/PRE&gt;&lt;P&gt;it just gets stuck and run's forever. Also even if it did somehow work I'm not sure how I would find out in my SAS program where to call that first variable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To clarify I want to:&lt;/P&gt;&lt;P&gt;1. Open a SAS enterprise .egp file from Excel VBA (this part works)&lt;/P&gt;&lt;P&gt;2. Pass it a paramter&amp;nbsp;&lt;/P&gt;&lt;P&gt;3. Run/exacute it (this also works)&lt;/P&gt;&lt;P&gt;4. Grab the csv file it prints out off the SAS server&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm also open to using "SYSPARM" but I havn't been able to get that to work.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Mar 2017 22:46:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Pass-a-Parameter-from-Excel-VBA-to-a-SAS-EG-project/m-p/344822#M22824</guid>
      <dc:creator>CalebSturges</dc:creator>
      <dc:date>2017-03-27T22:46:49Z</dc:date>
    </item>
    <item>
      <title>Re: Pass a Parameter from Excel VBA to a SAS EG project.</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Pass-a-Parameter-from-Excel-VBA-to-a-SAS-EG-project/m-p/344828#M22825</link>
      <description>When line:&lt;BR /&gt;Set parm = parmList.item(0)&lt;BR /&gt;it doesn't get stuck, it says invalid index 0 (because the list is empty.)</description>
      <pubDate>Mon, 27 Mar 2017 23:26:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Pass-a-Parameter-from-Excel-VBA-to-a-SAS-EG-project/m-p/344828#M22825</guid>
      <dc:creator>CalebSturges</dc:creator>
      <dc:date>2017-03-27T23:26:32Z</dc:date>
    </item>
    <item>
      <title>Re: Pass a Parameter from Excel VBA to a SAS EG project.</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Pass-a-Parameter-from-Excel-VBA-to-a-SAS-EG-project/m-p/344854#M22827</link>
      <description>&lt;P&gt;Hi &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/133867"&gt;@CalebSturges&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It looks like you are really close...&amp;nbsp; I&amp;nbsp;attempted&amp;nbsp;using EG 5.1 (32-bit w/ HF21) and Excel 2013 (32-bit)&amp;nbsp;and your code works for me with one change...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I commented out this line, since retrieving the DefaultValue property was causing an error, presumably since I didn't specify a default value for the prompt I defined:&lt;/P&gt;
&lt;PRE&gt;'Retrieving parm.DefaultValue causes error because no default value was set
'on the prompt I defined
'MsgBox parm.Name &amp;amp; " parameter has default value of " &amp;amp; parm.DefaultValue
MsgBox parm.Name &amp;amp; " parameter"&lt;/PRE&gt;
&lt;P&gt;In EG's View-&amp;gt;Prompt Manager, make sure you have at least one prompt defined.&amp;nbsp; For example, I accepted the defaults, which created a text prompt named "Prompt_1".&amp;nbsp; Then, I created a program in EG with this code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%put "&amp;amp;Prompt_1";
proc print data=sashelp.class;
where sex eq "&amp;amp;Prompt_1";
run;&lt;/PRE&gt;
&lt;P&gt;Then, make sure you associate the prompt with the program by clicking Properties on the program, Prompts page, then add the prompt you want to use with that program.&amp;nbsp; Run the program/project in EG&amp;nbsp;to make sure you get prompted and runs as expected.&amp;nbsp; If so,&amp;nbsp;delete the SAS results output (so you can easily tell if the project was re-run...&amp;nbsp; results recreated), save the project and close EG.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now when I run the VBA code, the value I specify ("M" or "F") is properly passed into the EG project and used in the code for me.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Casey&lt;/P&gt;</description>
      <pubDate>Tue, 28 Mar 2017 02:55:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Pass-a-Parameter-from-Excel-VBA-to-a-SAS-EG-project/m-p/344854#M22827</guid>
      <dc:creator>CaseySmith</dc:creator>
      <dc:date>2017-03-28T02:55:50Z</dc:date>
    </item>
  </channel>
</rss>

