设为首页收藏本站

EPS数据狗论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 1340|回复: 0

sas,log,output,ods输出管理(html output_object output_statement)

[复制链接]

22

主题

168

金钱

270

积分

入门用户

发表于 2019-7-2 13:21:37 | 显示全部楼层 |阅读模式

1:改变log输出到指定外部文件
log一般输出在log窗口,使用printto过程可以改变其默认输出位置
  1. proc printto log = "d:\log.txt" new; *将log输出到指定的文件中,new表示每次覆盖上一次,更多信息到时候查看帮助文档;
  2. proc print data=sashelp.class;
  3. proc printto; run; *恢复默认log输出;
复制代码

2:改变output输出到指定外部文件
  1. proc printto print='e:\log.txt';run;
  2. proc freq data=sashelp.class;
  3. table sex;
  4. run;
  5. proc printto;run;
  6. /*不知为何输出不到外部文件,以后再检查*/
复制代码

什么是ODS?
Output Delivery System

Ods有什么用?
determines where the output should go and what it should look like when it gets there.

理解Ods的基础是什么?
destinations:different types of ODS output
Template: is a set of instructions telling ODS how to format your data.

destinations:如果不指定输出目的地,那么默认为listing
下面是所有的输出目的地
  1. LISTING  standard SAS output
  2. HTML  Hypertext Markup Language
  3. RTF  Rich Text Format
  4. PRINTER  high-resolution printer output2
  5. PS  PostScript
  6. PCL  Printer Control Language
  7. PDF  Portable Document Format
  8. OUTPUT  SAS output data set
  9. MARKUP  markup languages including
  10. XML  DOCUMENT  output document
复制代码


Template = table template + style template
但是template的语法比较复杂,用已经设置好的内置类型就可以了
  1. PROC TEMPLATE;  
  2.   LIST STYLES;
  3. RUN;
复制代码


理解output object(简写为oo)
当sas从procedure中获取数据后,他会将data和table template组合成output object,对于一般过程来说只有一个output object,但对于含有by语句的程序来说,可以有很多,每个by组都可以有一个用ods trace statement来跟踪  用ods select来选择
语法如下
  1. ODS TRACE ON;
  2. the PROC steps you want to trace go here
  3. RUN;
  4. ODS TRACE OFF;
复制代码
  1. 日志对应的信息,证明确实有两个output object
  2.   ods trace off;
  3.   ods trace on;
  4.   proc means data=sashelp.class n mean maxdec=2;
  5.       by sex;
  6.      *ods select Means.ByGroup1.Summary;   /*这两句是我后面加进来的,运行程序是并不存在,表明选择需要输出的oo或需要排除的oo*/
  7.      *ods exclude Means.ByGroup1.Summary;
  8.   run;


  9. Output Added:
  10. -------------
  11. 名称:      Summary
  12. 标签:      汇总统计量
  13. 模板:      base.summary
  14. 路径:      Means.ByGroup1.Summary
  15. -------------
  16. NOTE: 上述消息针对以下 BY 组:
  17.       性别=男

  18. Output Added:
  19. -------------
  20. 名称:      Summary
  21. 标签:      汇总统计量
  22. 模板:      base.summary
  23. 路径:      Means.ByGroup2.Summary
  24. -------------
  25. NOTE: 上述消息针对以下 BY 组:
  26.       性别=女
复制代码


ods output statement
这条语句能输出任意对象到数据集,我现在不能经常用到,所以暂时不管。

ods html file='' style= ;
ods html close;
这两条语句对应出现,规定以html文件输出,以及输出的地方和style


3:利用ods改变输出路径
  1. filename outp 'C:\Users\Administrator\Desktop\myTestForToday\test.html';

  2. ods listing close; *改变默认输出路径listing;
  3. ods html file=outp; *打开指定;
  4. proc univariate data=sashelp.class;
  5.     var weight;
  6. run;
  7. ods html close;
  8. ods listing;
复制代码


4:ods results on/off对应结果查看集
程序比较大时,尽量关闭results管道,不然会占用很多资源。

5:输出需要的对象ods trace on/label;
  1. *列出过程中所有可以输出的模块;
  2. ods trace on/label;
  3. proc univariate data=sashelp.class;
  4.     class sex;
  5.     var   age;
  6. run;
  7. /*proc freq data=sashelp.class;*/
  8. /*    table sex;*/
  9. /*run;*/
  10. ods trace off;


  11. *其中一个模块的示例;
  12. Output Added:
  13. -------------
  14. 名称:      ExtremeObs  select后面的模块名
  15. 标签:      极值观测
  16. 模板:      base.univariate.ExtObs  
  17. 路径:      Univariate.Age.男.ExtremeObs   路径可以确定要输出的模块
  18. 标签路径:  'Univariate PROCEDURE'.'Age'.'Sex = 男'.'极值观测' 添加标签后才有。
复制代码

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

本版积分规则

关闭

站长推荐上一条 /1 下一条

客服中心
关闭
在线时间:
周一~周五
8:30-17:30
QQ群:
653541906
联系电话:
010-85786021-8017
在线咨询
客服中心

意见反馈|网站地图|手机版|小黑屋|EPS数据狗论坛 ( 京ICP备09019565号-3 )   

Powered by BFIT! X3.4

© 2008-2028 BFIT Inc.

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