0
votes

I'm trying to work in SAS with python (using saspy). I've just connected to remote machine with SSH and its okay. Also, I've found table that I need and everything seems to be fine. The problem occurs when I try to get the head() of dataset or describe it. The code and errors are below. I guess something wrong with output format or options that I include in config file (I mentioned only this 'options' : ["-fullstimer "] ).

sas = saspy.SASsession(cfgname='ssh')
dataset = sas.sasdata('tablename','libname')
dataset.head()

Internal code execution failed: ERROR 22-322: Syntax error, expecting one of the following: ;, ANTIALIAS, ANTIALIASMAX, BORDER, DISCRETEMAX, GROUPMAX,

1
The developers for saspy are on communities.sas.com but not on here. They'll be able to answer any questions you have regarding SASpy. Or you can just call tech support.Reeza
Only difference I see is that you don't specify the host, or at least that you've shown so far. sassoftware.github.io/saspy/getting-started.html#initial-importReeza
Does your SAS session actually have a libref name libname? And a dataset named libname.tablename? Try it with dataset = sas.sasdata('class','sashelp')Tom
yes, i wrote the right libname with saslib, i have no problems while getting data with sasdata, but with head() or describe() etc.kptkhv

1 Answers

0
votes

just happened to notice this. I have to remember to search here to find things. Any chance you can just open an issue on saspy: https://github.com/sassoftware/saspy/issues then I can more easily help you figure out what's going on.

To start with, can you show the actual code and output? Aslo submit the SASsession object and the SASdata object with that run:

>>> sas = saspy.SASsession(cfgname='ssh')
SAS Connection established. Subprocess id is 4777

No encoding value provided. Will try to determine the correct encoding.
Setting encoding to latin_1 based upon the SAS session encoding value of latin1.
>>> sas
Access Method         = SSH
SAS Config name       = ssh
SAS Config file       = /opt/tom/github/saspy/saspy/sascfg_personal.py
WORK Path             = /sastmp/SAS_workB62300004C67_tom64-4/
SAS Version           = 9.04.01M3D06242015
SASPy Version         = 3.1.8
Teach me SAS          = False
Batch                 = False
Results               = Pandas
SAS Session Encoding  = latin1
Python Encoding value = latin_1
SAS process Pid value = 19559


>>> dataset = sas.sasdata('cars','sashelp')
>>> dataset
Libref  = sashelp
Table   = cars
Dsopts  = {}
Results = Pandas

>>> dataset.head()
    Make           Model   Type Origin DriveTrain   MSRP  Invoice  EngineSize  Cylinders  Horsepower  MPG_City  MPG_Highway  Weight  Wheelbase  Length
0  Acura             MDX    SUV   Asia        All  36945    33337         3.5          6         265        17           23    4451        106     189
1  Acura  RSX Type S 2dr  Sedan   Asia      Front  23820    21761         2.0          4         200        24           31    2778        101     172
2  Acura         TSX 4dr  Sedan   Asia      Front  26990    24647         2.4          4         200        22           29    3230        105     183
3  Acura          TL 4dr  Sedan   Asia      Front  33195    30299         3.2          6         270        20           28    3575        108     186
4  Acura      3.5 RL 4dr  Sedan   Asia      Front  43755    39014         3.5          6         225        18           24    3880        115     197
>>>

Thanks! Tom

BTW, I have to search our communities site to find things too. Posting an issue to saspy is the best way to get help, FWIW.