<?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: Getting SAS script to run run from Python using SASPy in Developers</title>
    <link>https://communities.sas.com/t5/Developers/Getting-SAS-script-to-run-run-from-Python-using-SASPy/m-p/600118#M564</link>
    <description>Thanks &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/19924"&gt;@FriedEgg&lt;/a&gt;. In fact the Jupyter notebook and the SAS Grid are not on the same machine. So this was another problem. Both your solutions worked.</description>
    <pubDate>Tue, 29 Oct 2019 17:02:50 GMT</pubDate>
    <dc:creator>supp</dc:creator>
    <dc:date>2019-10-29T17:02:50Z</dc:date>
    <item>
      <title>Getting SAS script to run run from Python using SASPy</title>
      <link>https://communities.sas.com/t5/Developers/Getting-SAS-script-to-run-run-from-Python-using-SASPy/m-p/600076#M561</link>
      <description>&lt;P&gt;Hello, I am new to using Python. I developed a SAS program using Enterprise Guide on my windows devise. I would like to execute this program via a notebook in Jupyter Lab using Python 3.5.2. The notebook is running on a linux server.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I uploaded my .sas file to the linux server of the Jupyter notebook. I can successfully connect and create a SAS session on our Grid environment. The SAS session runs on a linux server. After installing and importing SASPY I try to submit the SAS script/file as follows:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;sas.submit('/users/myuserid/files/SAS_filename.sas')&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The program starts and runs for a while. It successfully creates librefs, then after the first data step I get this error:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;PRE&gt;3                                                          The SAS System                            08:16 Tuesday, October 29, 2019

21         ods listing close;ods html5 (id=saspy_internal) file=_tomods1 options(bitmap_mode='inline') device=svg style=HTMLBlue;
21       ! ods graphics on / outputfmt=png;
NOTE: Writing HTML5(SASPY_INTERNAL) Body file: _TOMODS1
22         ;*';*";*/;
23         /user/myuserid/files/SAS_filename.sas
           _
           180
ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;/PRE&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am not sure what this means or where to start with this. None of the ODS code is in my program. Any ideas as to what is happening here?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2019 14:19:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Getting-SAS-script-to-run-run-from-Python-using-SASPy/m-p/600076#M561</guid>
      <dc:creator>supp</dc:creator>
      <dc:date>2019-10-29T14:19:47Z</dc:date>
    </item>
    <item>
      <title>Re: Getting SAS script to run run from Python using SASPy</title>
      <link>https://communities.sas.com/t5/Developers/Getting-SAS-script-to-run-run-from-Python-using-SASPy/m-p/600078#M562</link>
      <description>&lt;P&gt;From the log snippet you posted it looks like SASpy is considering the string you gave as the actual SAS code to run. Not the name of a file.&amp;nbsp; So just change it to a valid SAS command.&amp;nbsp; Like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;sas.submit('%include "/users/myuserid/files/SAS_filename.sas";')&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Oct 2019 14:22:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Getting-SAS-script-to-run-run-from-Python-using-SASPy/m-p/600078#M562</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-10-29T14:22:37Z</dc:date>
    </item>
    <item>
      <title>Re: Getting SAS script to run run from Python using SASPy</title>
      <link>https://communities.sas.com/t5/Developers/Getting-SAS-script-to-run-run-from-Python-using-SASPy/m-p/600089#M563</link>
      <description>&lt;P&gt;See the SASPy API Reference&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://sassoftware.github.io/saspy/api.html#saspy.SASsession.submit" target="_blank"&gt;https://sassoftware.github.io/saspy/api.html#saspy.SASsession.submit&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using %include as Tom suggests would presume that Jupyter, where you said you uploaded the code, is the same machine where you are submitting to SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Two additional options you have:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. Ditch the .sas file and put it's contents directly into your notebook as such:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;results_dict = sas.submit(
             """
             libname tera teradata server=teracop1 user=user pw=pw;
             proc print data=tera.dsname (obs=10); run;
             """
             )&lt;/PRE&gt;
&lt;P&gt;2. Read the file contents into Python and then submit:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;code = open('/users/myuserid.files/SAS_filename.sas').read()
results_dict = sas.submit(code)&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2019 15:07:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Getting-SAS-script-to-run-run-from-Python-using-SASPy/m-p/600089#M563</guid>
      <dc:creator>FriedEgg</dc:creator>
      <dc:date>2019-10-29T15:07:33Z</dc:date>
    </item>
    <item>
      <title>Re: Getting SAS script to run run from Python using SASPy</title>
      <link>https://communities.sas.com/t5/Developers/Getting-SAS-script-to-run-run-from-Python-using-SASPy/m-p/600118#M564</link>
      <description>Thanks &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/19924"&gt;@FriedEgg&lt;/a&gt;. In fact the Jupyter notebook and the SAS Grid are not on the same machine. So this was another problem. Both your solutions worked.</description>
      <pubDate>Tue, 29 Oct 2019 17:02:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Getting-SAS-script-to-run-run-from-Python-using-SASPy/m-p/600118#M564</guid>
      <dc:creator>supp</dc:creator>
      <dc:date>2019-10-29T17:02:50Z</dc:date>
    </item>
    <item>
      <title>Re: Getting SAS script to run run from Python using SASPy</title>
      <link>https://communities.sas.com/t5/Developers/Getting-SAS-script-to-run-run-from-Python-using-SASPy/m-p/600120#M565</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;, thanks for the assist. Indeed I did not submit a valid SAS code.</description>
      <pubDate>Tue, 29 Oct 2019 17:03:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Getting-SAS-script-to-run-run-from-Python-using-SASPy/m-p/600120#M565</guid>
      <dc:creator>supp</dc:creator>
      <dc:date>2019-10-29T17:03:49Z</dc:date>
    </item>
  </channel>
</rss>

