想從網(wǎng)上下基金的歷史數(shù)據(jù),比如***上的數(shù)據(jù)
http://funds.money.hexun.com/fundsdata/open/summarize/data2.aspx?code=000001
我找到了下面這樣的用于下載網(wǎng)絡(luò)數(shù)據(jù)的代碼
/* 從yahoo.com讀取股票行情數(shù)據(jù)*/
%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;
/*
調(diào)用格式如:
%quotes (code=aol, prompt=YES);
%quotes (code=000001.SZ, start=4/1/00, end=4/10/2000);
其中:code為股票代碼,美國股票代碼不用加后綴,深市代碼后加.SZ,滬市代碼后加.SS,如000001.SZ為深發(fā)展代碼,
詳見http://finance.yahoo.com/l
start和end分別為起止日期,格式為mm/dd/yyyy
prompt:是否彈出窗口輸入上述參數(shù)
ps. 滬深股票行情數(shù)據(jù)好象每次最多只能下載200個記錄.
*/
%quotes (code=000001.SZ, start=1/1/2000, end=9/30/2005);
【【【【【【上面是轉(zhuǎn)的,原來的鏈接是:本文章轉(zhuǎn)自[聚享在線] 原文地址鏈接: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的用法,特別是對于網(wǎng)絡(luò)數(shù)據(jù)的用法,更特別的是對***上的這個數(shù)據(jù)的用法,有沒有大大可以指導(dǎo)一下。