<?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: Calling SAS from a script in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calling-SAS-from-a-script/m-p/154586#M12082</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It looks like you are using the EG Automation API. Using this API you can only use the possibilities that the EG API gives you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another approach would be to use the SAS Integration Technologies API (see &lt;A href="http://support.sas.com/documentation/cdl/en/itechwcdg/61500/PDF/default/itechwcdg.pdf" title="http://support.sas.com/documentation/cdl/en/itechwcdg/61500/PDF/default/itechwcdg.pdf"&gt;http://support.sas.com/documentation/cdl/en/itechwcdg/61500/PDF/default/itechwcdg.pdf&lt;/A&gt;).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or you give PowerShell and the Cmdlets4Sas a try: &lt;A class="active_link" href="http://sourceforge.net/p/cmdlets4sas/wiki/Building%20a%20poor%20man%27s%20enterprise%20guide/" title="http://sourceforge.net/p/cmdlets4sas/wiki/Building%20a%20poor%20man%27s%20enterprise%20guide/"&gt;Cmdlets4Sas / Wiki / Building a poor man&amp;amp;#39;s enterprise guide&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It would also help other people to help you if you would tell what you try to achieve.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 03 Nov 2014 14:49:46 GMT</pubDate>
    <dc:creator>AndreasMenrath</dc:creator>
    <dc:date>2014-11-03T14:49:46Z</dc:date>
    <item>
      <title>Calling SAS from a script</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calling-SAS-from-a-script/m-p/154584#M12080</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I found a fantastic article on calling SAS from a VBScript - either in EG or batch.&amp;nbsp; I am able to get either to work to run a program and get the log.&amp;nbsp; In the log, I can see that the datasets are created and the proc created output.&amp;nbsp; However, I can't programmatically access the dataset or the results.&amp;nbsp; I have looked over the object model, and everything looks like this should work fine.&amp;nbsp; The log says that 19 records were read for creating the new dataset, and 1 page was created when running a proc.&amp;nbsp; However, the code object's OutputDatasets and Results collection both have a count of 0.&amp;nbsp; Idea suggestions would be greatly appreciated.&amp;nbsp; If it helps, I am running SAS 9.2, EG 4.3.&amp;nbsp; Here is the code.&amp;nbsp; Sorry, I couldn't find the &amp;lt;code&amp;gt; tags.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;server = "\\nasvs1\Shared\4700Mac\shared2\Actuarial\SAS\"&lt;/P&gt;&lt;P&gt;projname = server &amp;amp; "Testing.egp"&lt;/P&gt;&lt;P&gt;codefiles = Array("LIBNAMES", "WORK")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Set oapp = CreateObject("SASEGObjectModel.Application.4.3")&lt;/P&gt;&lt;P&gt;Set oproj = oapp.Open(projname,"")&lt;/P&gt;&lt;P&gt;Set ocodecollect = oproj.CodeCollection&lt;/P&gt;&lt;P&gt;For Each code In codefiles&lt;/P&gt;&lt;P&gt;&amp;nbsp; For Each ocode In ocodecollect&lt;/P&gt;&lt;P&gt;&amp;nbsp; If ocode.Name = code Then&lt;/P&gt;&lt;P&gt;&amp;nbsp; ocode.Log.SaveAs server &amp;amp; ocode.Name &amp;amp; ".log"&lt;/P&gt;&lt;P&gt;&amp;nbsp; ocode.Run&lt;/P&gt;&lt;P&gt;&amp;nbsp; msgbox ocode.Name &amp;amp; ", OutputDatasets: " &amp;amp; ocode.OutputDatasets.Count&lt;/P&gt;&lt;P&gt;&amp;nbsp; msgbox ocode.Name &amp;amp; ", Results: " &amp;amp; ocode.Results.Count&lt;/P&gt;&lt;P&gt;&amp;nbsp; End If&lt;/P&gt;&lt;P&gt;&amp;nbsp; Next&lt;/P&gt;&lt;P&gt;Next&lt;/P&gt;&lt;P&gt;oproj.Save&lt;/P&gt;&lt;P&gt;oproj.Close&lt;/P&gt;&lt;P&gt;oapp.Quit&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Nov 2014 14:16:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calling-SAS-from-a-script/m-p/154584#M12080</guid>
      <dc:creator>cjohnson</dc:creator>
      <dc:date>2014-11-03T14:16:27Z</dc:date>
    </item>
    <item>
      <title>Re: Calling SAS from a script</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calling-SAS-from-a-script/m-p/154585#M12081</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If the SAS code actually creates a dataset in the library WORK, you won't be able to find anything, because WORK is dynamically created everytime a SAS session starts and deleted when it ends.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Nov 2014 14:21:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calling-SAS-from-a-script/m-p/154585#M12081</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2014-11-03T14:21:10Z</dc:date>
    </item>
    <item>
      <title>Re: Calling SAS from a script</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calling-SAS-from-a-script/m-p/154586#M12082</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It looks like you are using the EG Automation API. Using this API you can only use the possibilities that the EG API gives you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another approach would be to use the SAS Integration Technologies API (see &lt;A href="http://support.sas.com/documentation/cdl/en/itechwcdg/61500/PDF/default/itechwcdg.pdf" title="http://support.sas.com/documentation/cdl/en/itechwcdg/61500/PDF/default/itechwcdg.pdf"&gt;http://support.sas.com/documentation/cdl/en/itechwcdg/61500/PDF/default/itechwcdg.pdf&lt;/A&gt;).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or you give PowerShell and the Cmdlets4Sas a try: &lt;A class="active_link" href="http://sourceforge.net/p/cmdlets4sas/wiki/Building%20a%20poor%20man%27s%20enterprise%20guide/" title="http://sourceforge.net/p/cmdlets4sas/wiki/Building%20a%20poor%20man%27s%20enterprise%20guide/"&gt;Cmdlets4Sas / Wiki / Building a poor man&amp;amp;#39;s enterprise guide&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It would also help other people to help you if you would tell what you try to achieve.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Nov 2014 14:49:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calling-SAS-from-a-script/m-p/154586#M12082</guid>
      <dc:creator>AndreasMenrath</dc:creator>
      <dc:date>2014-11-03T14:49:46Z</dc:date>
    </item>
    <item>
      <title>Re: Calling SAS from a script</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calling-SAS-from-a-script/m-p/154587#M12083</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Wow.&amp;nbsp; I had no idea.&amp;nbsp; That did the trick.&amp;nbsp; You could not see what code I was running in SAS (my mistake), but I was creating dataset in work, running proc means, but the code object did not register any dataset or results.&amp;nbsp; When I switched to a permanent library, it worked. Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Nov 2014 15:12:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calling-SAS-from-a-script/m-p/154587#M12083</guid>
      <dc:creator>cjohnson</dc:creator>
      <dc:date>2014-11-03T15:12:35Z</dc:date>
    </item>
    <item>
      <title>Re: Calling SAS from a script</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calling-SAS-from-a-script/m-p/154588#M12084</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks!&amp;nbsp; My goal was just a sample script on my system where I could programmatically interact with the datasets and results.&amp;nbsp; I appreciate the link to the other API.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Nov 2014 15:13:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calling-SAS-from-a-script/m-p/154588#M12084</guid>
      <dc:creator>cjohnson</dc:creator>
      <dc:date>2014-11-03T15:13:29Z</dc:date>
    </item>
    <item>
      <title>Re: Calling SAS from a script</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calling-SAS-from-a-script/m-p/154589#M12085</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry to come back to this, but I think I have found the source of my problems.&amp;nbsp; I run this code in VBScript using the SAS EG API.&amp;nbsp; The first time I run it, the code file has no datasets or results.&amp;nbsp; The second time I run it (and subsequent), it does.&amp;nbsp; If I open the project and delete the dataset and result shortcut, and I rerun the script, it has no results again.&amp;nbsp; I would seem that even though I am running the code and then trying to access the dataset and results, they aren't there until after the project is saved, and then they can be accessed by the shortcuts.&amp;nbsp; Any thoughts on this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ocode.UseApplicationOptions = False &lt;/P&gt;&lt;P&gt;ocode.GenListing = True &lt;/P&gt;&lt;P&gt;ocode.GenSasReport = False &lt;/P&gt;&lt;P&gt;ocode.Log.SaveAs server &amp;amp; "Results\" &amp;amp; ocode.Name &amp;amp; ".log" &lt;/P&gt;&lt;P&gt;ocode.Run&lt;/P&gt;&lt;P&gt;ocode.SaveAs server &amp;amp; "Results\" &amp;amp; ocode.Name &amp;amp; ".sas"&lt;/P&gt;&lt;P&gt;msgbox ocode.Name &amp;amp; ", OutputDatasets: " &amp;amp; ocode.OutputDatasets.Count&lt;/P&gt;&lt;P&gt;msgbox ocode.Name &amp;amp; ", Results: " &amp;amp; ocode.Results.Count&lt;/P&gt;&lt;P&gt;For n=0 to (ocode.OutputDatasets.Count -1)&lt;/P&gt;&lt;P&gt;&amp;nbsp; dataName = ocode.OutputDatasets.Item(n).Name &lt;/P&gt;&lt;P&gt;&amp;nbsp; ocode.OutputDatasets.Item(n).SaveAs server &amp;amp; "Results\" &amp;amp; dataName &amp;amp; ".xls" &lt;/P&gt;&lt;P&gt;Next &lt;/P&gt;&lt;P&gt;For n=0 to (ocode.Results.Count -1) &lt;/P&gt;&lt;P&gt;&amp;nbsp; ocode.Results.Item(n).SaveAs server &amp;amp; "Results\" &amp;amp; WScript.ScriptName &amp;amp; n &amp;amp; ".lst"&lt;/P&gt;&lt;P&gt;Next &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Nov 2014 15:59:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calling-SAS-from-a-script/m-p/154589#M12085</guid>
      <dc:creator>cjohnson</dc:creator>
      <dc:date>2014-11-03T15:59:25Z</dc:date>
    </item>
  </channel>
</rss>

