SAS数据集操作-ODS输出

  SAS可以输出成HTML或PDF,这是通过使用SAS中提供的ODS语句来完成的。ODS代表输出传递系统,它主要用于格式化SAS程序的输出数据到好的报告,支持将多个PROC语句的结果合并到一个文件中。

基本语法:

ODS outputtype
PATH pathname
FILE = filename and path
STYLE = stylename
;
PROC some proc
;
ODS outputtype CLOSE;

参数描述: 

  • PATH表示在HTML输出的情况下使用的路径,其他类型的输出,文件名中包含路径;
  • STYLE表示SAS环境中提供的内置样式之一。

1.创建HTML输出

ODS HTML 
    PATH='/folders/myfolders/sasuser.v94/TutorialsPoint/'
    FILE='CARS2.html'
    STYLE=EGDefault;
proc SQL;
select make, model, invoice 
from sashelp.cars
where make in ('Audi','BMW')
and type = 'Sports'
;
quit;

proc SQL;
select make,mean(horsepower)as meanhp
from sashelp.cars
where make in ('Audi','BMW')
group by make;
quit;

ODS HTML CLOSE;

2.创建PDF输出

 

ODS PDF 
    FILE='/folders/myfolders/sasuser.v94/TutorialsPoint/CARS2.pdf'
    STYLE=EGDefault;
proc SQL;
select make, model, invoice 
from sashelp.cars
where make in ('Audi','BMW')
and type = 'Sports'
;
quit;

proc SQL;
select make,mean(horsepower)as meanhp
from sashelp.cars
where make in ('Audi','BMW')
group by make;
quit;

ODS PDF CLOSE;

 

3.创建RTF输出

RTF是Rich Text Format的缩写,意即多文本格式。这是一种类似DOC格式(Word文档)的文件,有很好的兼容性,使用Windows“附件”中的“写字板”就能打开并进行编辑。

 

ODS RTF 
FILE='/folders/myfolders/sasuser.v94/TutorialsPoint/CARS.rtf'
STYLE=EGDefault;
proc SQL;
select make, model, invoice 
from sashelp.cars
where make in ('Audi','BMW')
and type = 'Sports'
;
quit;

proc SQL;
select make,mean(horsepower)as meanhp
from sashelp.cars
where make in ('Audi','BMW')
group by make;
quit;

ODS rtf CLOSE; 

 

posted @ 2020-11-06 17:03  琳懿  阅读(1297)  评论(0)    收藏  举报