搜索
人大经济论坛 附件下载

附件下载

所在主题:
文件名:  新建 Microsoft Word 文档 (2).doc
资料下载链接地址: https://bbs.pinggu.org/a-1309059.html
附件大小:
为了能够及时跟踪证券市场的行情,证券分析师或者投资者需要及时“刷新”浏览器来检查各类报价。那么,如何以SAS系统为平台从互联网上直接获取证券报价?这里将通过一个简短的SAS程序和宏代码,展示如何基于SAS URL技术来检索广域或者局域网站的数据。这样,有兴趣的人们便可以基于SAS平台,通过数据分析来把握证券的实时走势了。
/*------------------------------------------------------------------*/
/* Ticker.sas – A Simple Stock Quote Retrieval Program */
/*------------------------------------------------------------------*/

filename in url
"
http://finance.yahoo.com:80/d/quotes.txt?s=YHOO+IBM+HPQ&f=sl1d1t1c1ohgv&e=.txt)";
data;
infile in dsd end=eof termstr=crlf;
input Ticker : $4. Price TradeDate : $10. TradeTime: $7. Change Open High Low Volume;
options nodate nonumber nocenter ls=70;
proc print width=u;
title 'Stock Quotes';
id Ticker;
run;

/*-----------------------------------------------------------------------*/
/* TickerMacro.sas – Stock Quote Retrieval With Refresh */
/* Parameters: */
/* SYMBOLS stock symbols */
/* SLEEPseconds between stock quote refreshes */
/* MAX number of times to refresh stock quotes */
/* OUT sas data set name containing stock quotes */
/*------------------------------------------------------------------------*/

%macro GetQuotes(Symbols=, Sleep=1, Max=10,Out=work.getquotes);
*--> Fetch Stock Quotes Specified Number Of Times;
%do i=1 %to &max;

filename in url
"
http://finance.yahoo.com:80/d/quotes.txt?s=&symbols.&f=sl1d1t1c1ohgv&e=.txt)";
*--> Retrieve Stock Quotes From Yahoo;
data;
infile in dsd end=eof termstr=crlf;
input Ticker : $4. Price TradeDate : $10. TradeTime: $7. Change Open Hi Lo
Volume;
AsOf=put(today(),yymmdd10.)||' At '|| put(time(),time8.);
*--> Add Stock Quotes To SAS Data Set;
proc append base=&out data=_last_;
options nodate nonumber nocenter ls=70 ps=1000;
*--> Produce Cumulative Stock Quote Comparison Report;
proc tabulate data=GetQuotes;
Title Stock Quotes By Ticker;
class Ticker AsOf TradeDate TradeTime;
var Price Change;
tables Ticker*AsOf*TradeDate*TradeTime, (Price Change)*f=7.2 / rts=50;
keylabel sum=' ';
*--> Pause Specified Number Of Seconds Between Refreshes;
data;
%if &i<=&max %then
x=sleep(&sleep);;
run;

%end;
%mend;
/* Get Quotes For Yahoo, IBM, and Hewlett Packard Wait 5 Minutes (300 */
/* Seconds) Before Refreshing Stock Quotes Refresh Quotes 36 Times */
/*%GetQuotes(Symbols=YHOO+IBM+HPQ, Sleep=300, Max=36);*/
%GetQuotes(Symbols=YHOO+IBM+HPQ, Sleep=10, Max=5);

/* 看官,请点击帖子左下角的“评分”给点鼓励吧! */



    熟悉论坛请点击新手指南
下载说明
1、论坛支持迅雷和网际快车等p2p多线程软件下载,请在上面选择下载通道单击右健下载即可。
2、论坛会定期自动批量更新下载地址,所以请不要浪费时间盗链论坛资源,盗链地址会很快失效。
3、本站为非盈利性质的学术交流网站,鼓励和保护原创作品,拒绝未经版权人许可的上传行为。本站如接到版权人发出的合格侵权通知,将积极的采取必要措施;同时,本站也将在技术手段和能力范围内,履行版权保护的注意义务。
(如有侵权,欢迎举报)
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

GMT+8, 2025-12-27 02:49