想从网上下基金的历史数据,比如***上的数据
http://funds.money.hexun.com/fundsdata/open/summarize/data2.aspx?code=000001
我找到了下面这样的用于下载网络数据的代码
/* 从yahoo.com读取股票行情数据*/
%macro quotes (code=, start=, end=, prompt=NO);
%local code start end;
%local s _start _end a b c d e f g url;
%if (%superq(code) eq ) %then %let code=000001.SZ;
%let code = %upcase (&code);
%if (%superq(end) eq )
%then %let end = %sysfunc(today(),mmddyy8);
%if (%superq(start) eq ) %then %do;
%let start = %sysfunc(inputn(&end,mmddyy8.));
%let start = %eval (&start-30);
%let start = %sysfunc(putn(&start,mmddyy8.));
%end;
%if (%upcase(&prompt) eq YES) %then %do;
%window quotes rows=12 columns=30
[email=#2@2]#2@2[/email] "code: " code 4 c=blue a=rev_video
[email=#4@2]#4@2[/email] "Start: " start 8 c=blue a=rev_video
[email=#6@2]#6@2[/email] "End: " end 8 c=blue a=rev_video
;
%display quotes;
%end;
%let code = %upcase (&code);
%if (%superq(end) eq )
%then %let _end = %sysfunc(today());
%else %let _end = %sysfunc(inputn(&end ,mmddyy10.));
%if (%superq(start) eq )
%then %let _start = %eval (&_end-30);
%else %let _start = %sysfunc (inputn(&start,mmddyy10.));
%let s = &code;
%let a = %sysfunc (month(&_start)); %let a=%eval(&a-1);
%let b = %sysfunc (day (&_start));
%let c = %sysfunc (year (&_start));
%let d = %sysfunc (month(&_end)); %let d=%eval(&d-1);
%let e = %sysfunc (day (&_end));
%let f = %sysfunc (year (&_end));
%let g = d;
%let and = %str(&);
%let url = http://ichart.finance.yahoo.com/table.csv;
%let url = &url.?s=&s;
%let url = &url.&and.a=&a.&and.b=&b.&and.c=&c;
%let url = &url.&and.d=&d.&and.e=&e.&and.f=&f;
%let url = &url.&and.g=&g;
%let url = &url.&and.ignore=.csv;
%put &url;
filename quotes URL "&url";
data stockquotes;
infile quotes dlm=",";
retain code "&code";
if _n_ = 1 then input; * skip header row;
input date date9. opening highest lowest closing volume;
format date yymmdd10.;
format volume comma11.;
run;
%bye:
%mend;
/*
调用格式如:
%quotes (code=aol, prompt=YES);
%quotes (code=000001.SZ, start=4/1/00, end=4/10/2000);
其中:code为股票代码,美国股票代码不用加后缀,深市代码后加.SZ,沪市代码后加.SS,如000001.SZ为深发展代码,
详见http://finance.yahoo.com/l
start和end分别为起止日期,格式为mm/dd/yyyy
prompt:是否弹出窗口输入上述参数
ps. 沪深股票行情数据好象每次最多只能下载200个记录.
*/
%quotes (code=000001.SZ, start=1/1/2000, end=9/30/2005);
【【【【【【上面是转的,原来的链接是:本文章转自[聚享在线] 原文地址链接:http://www.510050.com/Article/txyj/201105/74759.shtml】】】】】】我就不处理了,对得起原著
我差不多知道最有用的是
filename quotes URL "&url";
data stockquotes;
infile quotes dlm=",";
retain code "&code";
if _n_ = 1 then input; * skip header row;
input date date9. opening highest lowest closing volume;
format date yymmdd10.;
format volume comma11.;
run;
%bye:
%mend;
这一段。而这一段中的filename的用法,特别是对于网络数据的用法,更特别的是对***上的这个数据的用法,有没有大大可以指导一下啊?