楼主: bobguy
3130 4

[原创博文] Download trading data from yahoo finance [推广有奖]

学科带头人

7%

还不是VIP/贵宾

-

威望
0
论坛币
14187 个
通用积分
28.9279
学术水平
344 点
热心指数
363 点
信用等级
228 点
经验
104882 点
帖子
1846
精华
0
在线时间
1608 小时
注册时间
2008-7-18
最后登录
2019-3-8

中级热心勋章

楼主
bobguy 发表于 2011-12-27 13:29:32 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
data _null_;
  stkname='bidu';
  startdate=mdy(12,1,2011);
  enddate=mdy(12,26,2011);
  file 'Desktop\stock.sas';


  ***********do not edit***********************;
  stkname=upcase(stkname);
  m1=month(startdate)-1;
  d1=day(startdate);
  y1=year(startdate);
  m2=month(enddate)-1;
  d2=day(enddate);
  y2=year(enddate);
  filen=catt('filename mkt URL ', "'",'http://table.finance.yahoo.com:80/table.csv?s=',stkname,
             '&a=',m1,'&b=',d1,'&c=',y1,'&d=',m2,'&e=',d2,'&f=',y2,'&g=d',"';");
  put filen;
  put 'data '  stkname ';';
  put 'length Stkname $4 Date 8 Day $3 Open High Low Close Volume 8;';
  put "infile mkt dlm=',' firstobs=2;";
  put "input Date yymmdd10. Open High Low Close Volume; ";
  put "stkname='" stkname "';";
  put "Day=upcase(strip(put(date, weekdatx.)));";
  put "format Date date9. Volume comma11.;run;";
  run;

  %include 'Desktop\stock.sas';

  proc print;run;
二维码

扫码加我 拉你入群

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

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

关键词:download Finance Trading Financ rading Download finance Desktop yahoo null

已有 1 人评分学术水平 热心指数 信用等级 收起 理由
yugao1986 + 1 + 1 + 1 精彩帖子

总评分: 学术水平 + 1  热心指数 + 1  信用等级 + 1   查看全部评分

沙发
bobguy 发表于 2011-12-28 03:53:48
This one uses call execute.

data _null_;
  stkname='bidu';
  startdate=mdy(12,1,2011);
  enddate=mdy(12,26,2011);
  
  ***********do not edit***********************;
  stkname=upcase(stkname);
  m1=month(startdate)-1;
  d1=day(startdate);
  y1=year(startdate);
  m2=month(enddate)-1;
  d2=day(enddate);
  y2=year(enddate);
  filen=catt('filename mkt URL ', "'",'http://table.finance.yahoo.com:80/table.csv?s=',stkname,
             '&a=',m1,'&b=',d1,'&c=',y1,'&d=',m2,'&e=',d2,'&f=',y2,'&g=d',"';");
  call execute( filen);
  call execute(  'data ' || stkname || ';') ;
  call execute(  'length Stkname $4 Date 8 Day $3 Open High Low Close Volume 8;');
  call execute(  "infile mkt dlm=',' firstobs=2;");
  call execute(  "input Date yymmdd10. Open High Low Close Volume; ");
  call execute(  "stkname='" || stkname || "';");
  call execute(  "Day=upcase(strip(put(date, weekdatx.)));");
  call execute(  "format Date date9. Volume comma11.;run;");
  run;

  

  proc print;run;

藤椅
ryuuzt 发表于 2011-12-28 19:42:20
很好,学习了。
如果再有一些解释,对初学者就更有帮助了。

板凳
zgp480 发表于 2013-4-29 02:41:37
可以把它写成Macro吗?我没有写成。

报纸
goldbaodi 发表于 2013-4-29 13:09:25

很好,学习了。

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2026-1-1 00:49