URL にアクセスしようとしていて、データをデータセットに保存し、ファイルを JSON として出力したいと考えています。
URLデータを取得してJSONファイルとして保存したいだけですが、私の質問には2つの部分があります......
- URL 応答データが既にhttp://headers.jsontest.comのような json 形式である場合は
file
、put
コマンドとjson
拡張子付きのコマンドを使用するだけです - URL 応答データが
html tags
他の URL データと同様である場合、json
SAS によって解析またはフォーマットに変換できます。
http://www.google.comまたはhttp://headers.jsontest.comと仮定してフェッチしようとしました....ここに私のコードがあります.....
LIBNAME src '/home/user/readURL';
filename test_url url 'http://headers.jsontest.com' debug lrecl=8192;
data src.http;
infile test_url length=len;
input record $varying8192. len;
file '/home/user/readURL/READ_URL.txt';
put test_url;
run;
proc print data = src.http;
run;
これは、コードを実行した後に得たエラー メッセージを含むログ ファイルです: ERROR: The connection has timed out..
これを取り除く方法を考えてみてください.....
2 The SAS System 07:57 Wednesday, January 15, 2014
16 filename test_url url 'http://headers.jsontest.com' debug lrecl=8192;
17 data src.http;
18 infile test_url length=len;
19 input record $varying8192. len;
20 run;
ERROR: The connection has timed out..
NOTE: The SAS System stopped processing this step because of errors.
NOTE: SAS set option OBS=0 and will continue to check statements. This may cause NOTE: No observations in data set.
WARNING: The data set SRC.HTTP may be incomplete. When this step was stopped there were 0 observations and 1 variables.
WARNING: Data set SRC.HTTP was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 1:14.92
cpu time 0.03 seconds
READ_URL.txt
空のファイルとして取得
事前に助けてくれてありがとう...