<?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: Using Python Code inside Proc FCMP in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Using-Python-Code-inside-Proc-FCMP/m-p/882961#M348883</link>
    <description>&lt;P&gt;I can't speak to your overall workflow, but the error you're getting is because you need the keyword for that value: cfgfile=&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=""&gt;sas = saspy.SASsession(cfgfile='E:\Program Files\Python311\Lib\site-packages\saspy\sascfg_personal.py')&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;All parameters for SASsession are keyword, not positional. So, that should get rid of this error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tom&lt;/P&gt;</description>
    <pubDate>Thu, 29 Jun 2023 15:26:46 GMT</pubDate>
    <dc:creator>sastpw</dc:creator>
    <dc:date>2023-06-29T15:26:46Z</dc:date>
    <item>
      <title>Using Python Code inside Proc FCMP</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-Python-Code-inside-Proc-FCMP/m-p/882879#M348838</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to use python inside a proc fcmp.&amp;nbsp; I configure the sascfg_personal.py to use&amp;nbsp;winiomwin but when the session is starting present the follow error message:&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR: Micro Analytic Service failed to execute method&lt;BR /&gt;ERROR: Python execution: Traceback (most recent call last): File "E:\SAS\SASHome\SASFoundation\9.4\tkmas\sasmisc\mas2py.py", line&lt;BR /&gt;394, in execute out = up[1].get(func)[0](up[0])(*parms) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File&lt;BR /&gt;"C:\Users\sasdemo\AppData\Local\Temp\tmplfbeub0i\py.py", line 5, in sasReadWrite sas = saspy.SASsession('E:\Program&lt;BR /&gt;Files\Python311\Lib\site-packages\saspy\sascfg_personal.py')&amp;nbsp; &amp;nbsp;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^TypeError: SASsession.__init__()&lt;BR /&gt;takes 1 positional argument but 2 were given&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the SAS code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc fcmp;
length workpath outfile $ 500;
workpath = pathname('work');
file log;
declare object py(python);
submit into py;
def sasReadWrite(workpath):
	"""Output: output_table"""
	import pandas as pd
	import saspy;
	sas = saspy.SASsession('E:\Program Files\Python311\Lib\site-packages\saspy\sascfg_personal.py')
	ds = sas.sasdata(table='AIR', libref='SASHELP')
	df_from_sd  = ds.to_df()
	sas.saslib(libref='out', path = workpath)
	outds = sas.dataframe2sasdata(
	df = df_from_sd,
		libref = 'out',
		table = 'final',
		encode_errors = 'replace'
	)

	sas.endsas()
	return outds.table
endsubmit;

	rc = py.publish();
	rc = py.call('sasReadWrite', workpath);
	outfile = py.results['output_table'];
	if not missing(outfile) then 
		put 'Output dataset:' outfile;
run;

proc print data=final(obs=10);
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Jun 2023 00:31:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-Python-Code-inside-Proc-FCMP/m-p/882879#M348838</guid>
      <dc:creator>radhames_gomez</dc:creator>
      <dc:date>2023-06-29T00:31:55Z</dc:date>
    </item>
    <item>
      <title>Re: Using Python Code inside Proc FCMP</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-Python-Code-inside-Proc-FCMP/m-p/882961#M348883</link>
      <description>&lt;P&gt;I can't speak to your overall workflow, but the error you're getting is because you need the keyword for that value: cfgfile=&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=""&gt;sas = saspy.SASsession(cfgfile='E:\Program Files\Python311\Lib\site-packages\saspy\sascfg_personal.py')&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;All parameters for SASsession are keyword, not positional. So, that should get rid of this error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tom&lt;/P&gt;</description>
      <pubDate>Thu, 29 Jun 2023 15:26:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-Python-Code-inside-Proc-FCMP/m-p/882961#M348883</guid>
      <dc:creator>sastpw</dc:creator>
      <dc:date>2023-06-29T15:26:46Z</dc:date>
    </item>
    <item>
      <title>Re: Using Python Code inside Proc FCMP</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-Python-Code-inside-Proc-FCMP/m-p/882987#M348896</link>
      <description>&lt;P&gt;Hey Tom,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my sascfg_personal.py the SAS Config Name =&amp;nbsp;winiomwin.&amp;nbsp; &amp;nbsp;Should i change the&amp;nbsp;cfgfile value to winiomwin. ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Jun 2023 18:27:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-Python-Code-inside-Proc-FCMP/m-p/882987#M348896</guid>
      <dc:creator>radhames_gomez</dc:creator>
      <dc:date>2023-06-29T18:27:14Z</dc:date>
    </item>
    <item>
      <title>Re: Using Python Code inside Proc FCMP</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-Python-Code-inside-Proc-FCMP/m-p/882988#M348897</link>
      <description>&lt;P&gt;Have you tried using SASPy outside of proc fcmp, so you can figure out how it works and see if what you are doing is correct? Trying to figure out what's wrong from running inside of proc fcmp isn't going to work. cfgfile is the path of the config file you want to use, when you don't simply have it in any of the search paths where it would already be found. cfgname is the name of a config definition in that file (python Dict with config values). So, no, that wouldn't make sense. You're just running this with a local SAS install on your PC? Just run Python and SASPy there outside of SAS to get a connection and see that what you're trying to do is correct.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Jun 2023 18:43:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-Python-Code-inside-Proc-FCMP/m-p/882988#M348897</guid>
      <dc:creator>sastpw</dc:creator>
      <dc:date>2023-06-29T18:43:01Z</dc:date>
    </item>
    <item>
      <title>Re: Using Python Code inside Proc FCMP</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-Python-Code-inside-Proc-FCMP/m-p/883726#M349145</link>
      <description>&lt;P&gt;Did you get this working? Was that syntax error the only issue?&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jul 2023 13:40:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-Python-Code-inside-Proc-FCMP/m-p/883726#M349145</guid>
      <dc:creator>sastpw</dc:creator>
      <dc:date>2023-07-06T13:40:50Z</dc:date>
    </item>
  </channel>
</rss>

