0

我正在尝试使用 python(使用 saspy)在 SAS 中工作。我刚刚用 SSH 连接到远程机器,没关系。另外,我找到了我需要的桌子,一切似乎都很好。当我尝试获取数据集的 head() 或描述它时,就会出现问题。代码和错误如下。我猜我在配置文件中包含的输出格式或选项有问题(我只提到了这个'options' : ["-fullstimer "])。

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

内部代码执行失败:错误 22-322:语法错误,期待以下之一:;,ANTIALIAS,ANTIALIASMAX,BORDER,DISCRETEMAX,GROUPMAX,

4

1 回答 1

0

刚好注意到这一点。我必须记得在这里搜索才能找到东西。任何机会您都可以在 saspy 上打开一个问题:https ://github.com/sassoftware/saspy/issues 然后我可以更轻松地帮助您弄清楚发生了什么。

首先,您能显示实际的代码和输出吗?Aslo 使用该运行提交 SASsession 对象和 SASdata 对象:

>>> 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
>>>

谢谢!汤姆

顺便说一句,我也必须搜索我们的社区网站才能找到东西。FWIW,向 saspy 发布问题是获得帮助的最佳方式。

于 2019-11-22T21:08:51.153 回答