<?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: Excel VBA Stored Process with parameters in Microsoft Integration with SAS</title>
    <link>https://communities.sas.com/t5/Microsoft-Integration-with-SAS/Excel-VBA-Stored-Process-with-parameters/m-p/21863#M448</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well, there's a very simple explanation. This paper uses many new features available from Office-Addin 4.3. Where I work they installed 4.2 and the upgrade seems to be far away...&lt;/P&gt;&lt;P&gt;Anyway, I think it is always good to have some tricks under the sleeve, isn't it?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 25 Jul 2012 14:03:50 GMT</pubDate>
    <dc:creator>KenjiAneel</dc:creator>
    <dc:date>2012-07-25T14:03:50Z</dc:date>
    <item>
      <title>Excel VBA Stored Process with parameters</title>
      <link>https://communities.sas.com/t5/Microsoft-Integration-with-SAS/Excel-VBA-Stored-Process-with-parameters/m-p/21860#M445</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm trying to run a macro that 1)connects to a SAS server from a remote computer, 2) Submits a command to run a stored process, 3) submits parameters for the stored process.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So far, I had partial success in 1) and 2), but I can't submit a parameter for the stored process. I tried the code: SASproc.Execute "TESTVBA", "param=1", but it didn't work at all. &lt;/P&gt;&lt;P&gt;I tried to insert a macro "GLOBAL param; *processbody; %let param=;", and also tried to set a prompt "param", but neither worked. Any guess anyone? The VBA code goes as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dim sasObjectFactory As New SASObjectManager.ObjectFactory&lt;BR /&gt;Dim obSAS As SAS.Workspace&lt;BR /&gt;Dim LoginDef As SASObjectManager.LoginDef&lt;/P&gt;&lt;P&gt;Dim ServerDef As New SASObjectManager.ServerDef&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ServerDef.Protocol = ProtocolBridge&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ServerDef.MachineDNSName = "just.asample.net"&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ServerDef.Port = 8591&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;Dim SASObjectKeeper As SASObjectManager.ObjectKeeper&lt;/P&gt;&lt;P&gt;Dim obLibRef As SAS.Libref&lt;/P&gt;&lt;P&gt;Dim sasLanguageEvent As SAS.LanguageService&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Set sasObjectFactory = New SASObjectManager.ObjectFactory&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Set obSAS = sasObjectFactory.CreateObjectByServer("Server", True, ServerDef, "someone", "********")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Set sasLanguageEvent = obSAS.LanguageService&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Set SASObjectKeeper = New SASObjectManager.ObjectKeeper&lt;BR /&gt;SASObjectKeeper.AddObject 1, "Server", obSAS&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;Dim SASproc As SAS.StoredProcessService&lt;/P&gt;&lt;P&gt;Set SASproc = obSAS.LanguageService.StoredProcessService&lt;BR /&gt;SASproc.Repository = "file:f:\path"&lt;BR /&gt;sasLanguageEvent.Submit ParaSAS&lt;BR /&gt;SASproc.Execute "TESTVBA", "param=1"&lt;/P&gt;&lt;P&gt;End Sub&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Dec 2011 11:40:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Microsoft-Integration-with-SAS/Excel-VBA-Stored-Process-with-parameters/m-p/21860#M445</guid>
      <dc:creator>KenjiAneel</dc:creator>
      <dc:date>2011-12-30T11:40:47Z</dc:date>
    </item>
    <item>
      <title>Re: Excel VBA Stored Process with parameters</title>
      <link>https://communities.sas.com/t5/Microsoft-Integration-with-SAS/Excel-VBA-Stored-Process-with-parameters/m-p/21861#M446</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well, it turns out it is very easy.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just use the sasLanguageEvent.Submit to submit a macro command&lt;/P&gt;&lt;P&gt;for example, you can use to submit a parameter set in a A2 cell in Excel:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SasLanguageEvent.Submit("%let Parameter = " &amp;amp; Plan1.range("A2") &amp;amp; ";")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;then run a Stored Process which you use this command such as:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; data weekday;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dayofWeek = "&amp;amp;Parameter";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You also can submit a data step which creates a set of parameters such as:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dim SAScommand(2) as string&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SAScommand(0) = "data createdata;"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SAScommand(1)="data1=" &amp;amp; Plan1.Range("a1") &amp;amp; "; data2 =" &amp;amp; Plan1.Range("a2") &amp;amp; ";"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SAScommand(2)="run;"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;With those basically there's nothing you can not do &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;You just have to be aware of some kinds of variables, such as dates and decimal numbers.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rgds&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Jul 2012 14:36:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Microsoft-Integration-with-SAS/Excel-VBA-Stored-Process-with-parameters/m-p/21861#M446</guid>
      <dc:creator>KenjiAneel</dc:creator>
      <dc:date>2012-07-19T14:36:48Z</dc:date>
    </item>
    <item>
      <title>Re: Excel VBA Stored Process with parameters</title>
      <link>https://communities.sas.com/t5/Microsoft-Integration-with-SAS/Excel-VBA-Stored-Process-with-parameters/m-p/21862#M447</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Thanks for posting your solution.&lt;/P&gt;&lt;P&gt;I'm just starting to play with Excel&amp;lt;-&amp;gt;Stored Process integration via VBA.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Was wondering if you could explain why you went with your approach, rather than using VBA to script the excel-addin, as described in:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/resources/papers/proceedings11/012-2011.pdf" title="http://support.sas.com/resources/papers/proceedings11/012-2011.pdf"&gt;http://support.sas.com/resources/papers/proceedings11/012-2011.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;--Q.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Jul 2012 23:36:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Microsoft-Integration-with-SAS/Excel-VBA-Stored-Process-with-parameters/m-p/21862#M447</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2012-07-24T23:36:45Z</dc:date>
    </item>
    <item>
      <title>Re: Excel VBA Stored Process with parameters</title>
      <link>https://communities.sas.com/t5/Microsoft-Integration-with-SAS/Excel-VBA-Stored-Process-with-parameters/m-p/21863#M448</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well, there's a very simple explanation. This paper uses many new features available from Office-Addin 4.3. Where I work they installed 4.2 and the upgrade seems to be far away...&lt;/P&gt;&lt;P&gt;Anyway, I think it is always good to have some tricks under the sleeve, isn't it?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Jul 2012 14:03:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Microsoft-Integration-with-SAS/Excel-VBA-Stored-Process-with-parameters/m-p/21863#M448</guid>
      <dc:creator>KenjiAneel</dc:creator>
      <dc:date>2012-07-25T14:03:50Z</dc:date>
    </item>
    <item>
      <title>Re: Excel VBA Stored Process with parameters</title>
      <link>https://communities.sas.com/t5/Microsoft-Integration-with-SAS/Excel-VBA-Stored-Process-with-parameters/m-p/21864#M449</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Abosolutely, always nice to see more than one way to approach a problem!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Jul 2012 14:24:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Microsoft-Integration-with-SAS/Excel-VBA-Stored-Process-with-parameters/m-p/21864#M449</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2012-07-25T14:24:14Z</dc:date>
    </item>
    <item>
      <title>Re: Excel VBA Stored Process with parameters</title>
      <link>https://communities.sas.com/t5/Microsoft-Integration-with-SAS/Excel-VBA-Stored-Process-with-parameters/m-p/21865#M450</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Solution:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In your SAS code (i.e. your stored process), after defining your variables, add the following line of code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*processbody;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;All your remaining SAS code should follow.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Hope this helps.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Nov 2013 03:48:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Microsoft-Integration-with-SAS/Excel-VBA-Stored-Process-with-parameters/m-p/21865#M450</guid>
      <dc:creator>Dan07</dc:creator>
      <dc:date>2013-11-06T03:48:50Z</dc:date>
    </item>
  </channel>
</rss>

