BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
sasone
Quartz | Level 8

いつも大変お世話になっております。
現在SASPyを使用してSAS Ondemandと手持ちのJupyter Notebook(Anaconda3)とを連携させております。
SAS Ondemandで出力したテキストファイルは仮想的空間に存在しており、一方Jupyterはローカル環境にあるためテキストファイルをPythonで直接読み取ることができません。
どのようなPATHを切ればSAS OndemandのテキストファイルをローカルのPythonに直接呼び込むことができますでしょうか。
プログラム例は以下になります。ご教示の程何卒よろしくお願いいたします。

import saspy
sas=saspy.SASsession

%%SAS
filename resp "./newsFeed.txt";
proc http 
   url="https://news.yahoo.co.jp" 
   out=resp;
run;

# coding: utf-8
f=open("./newsFeed.txt",'r',encoding="UTF-8")
r=f.read()
f.close()
print(r) 

 

1 ACCEPTED SOLUTION

Accepted Solutions
sas7016
SAS Employee

一旦ローカルにテキストファイルをダウンロード後、Pythonで読み込むのはいかがでしょうか。

sas.download("./newsFeed_local.txt", "~/newsFeed.txt")
f=open("./newsFeed_local.txt",'r',encoding="UTF-8") r=f.read() f.close() print(r)

参照: saspy API Reference

View solution in original post

3 REPLIES 3
japelin
Rhodochrosite | Level 12

直接の回答ではありませんが。

 

SAS OnDemand for AcademicsにおけるSAS Studioはサーバ外の参照が一切できません。

(企業ネットワーク内におけるSAS Studioではそうでないと思いますが)

 

そのため、FILENAME FTPでFTPサーバにアップロードしてPythonでFTPダウンロードする、

といった感じで中間サーバを経由する方法しかないように思います。

sas7016
SAS Employee

一旦ローカルにテキストファイルをダウンロード後、Pythonで読み込むのはいかがでしょうか。

sas.download("./newsFeed_local.txt", "~/newsFeed.txt")
f=open("./newsFeed_local.txt",'r',encoding="UTF-8") r=f.read() f.close() print(r)

参照: saspy API Reference

sasone
Quartz | Level 8

sas7016さま

早速のご回答、誠に有難うございます。

ご教示頂いた方法で全てうまく行きました。

ありがとうございました。

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Discussion stats
  • 3 replies
  • 1265 views
  • 4 likes
  • 3 in conversation