统计211

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 3045|回复: 0
打印 上一主题 下一主题

SAS以流的方式读取、写入文件

[复制链接]
跳转到指定楼层
1
发表于 2011-7-1 13:28:52 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
  length rec $256 crc $1 rc 8;
  init:
  submit continue;
  filename h url "
  data crlibm.report_xls(compress=yes);
  infile h;
  input rec $char256.;
  rpt_id=1;rownum=_n_;
  run;
  endsubmit;
  /*如果crlibm置于spde引擎之下,由于多线程读取的原因,不能保证rownum顺序获得*/
  submit continue;
  proc sql;
  create view v1 as
  select * from crlibm.report_xls
  where rpt_id=1
  order by rownum;
  endsubmit;
  'Content-type','application/vnd.ms-excel');
  'Content-disposition','attachment;filename=t.xls');
  /*IT下,由于data step中无法设定_webout的文件属性,导致xls流不能正确输出*/
  fid=fopen('_webout','A',0,'B');
  dsid=open('v1');
  do while(fetch(dsid)^=-1);
  rec=getvarc(dsid,1);
  rc=fput(fid,put(rec,$char256.));
  rc=fwrite(fid);
  end;
  dsid=close(dsid);
  fid=fclose(fid);
  return;
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 转播转播 分享分享 分享淘帖 支持支持 反对反对
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则


免责声明|关于我们|小黑屋|联系我们|赞助我们|统计211 ( 闽ICP备09019626号  

GMT+8, 2025-4-19 11:46 , Processed in 0.082627 second(s), 22 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表