继续《SAS编程与数据挖掘商业案例》学习笔记系列,本次重点:常用全程语句
所谓全程语句,是指可以用在任何地方的sas语句,既可以用在data数据步语句里面,也可以用在proc过程步里面,甚至可以单独使用,本次只针对商业应用中常用的语句进行总结:
1.comments语句
形式有两种:
*comment
也可以用快捷方式:ctrl ?,取消comments可以用ctrl shit ?
2.filename语句
常用的语句:
Filename out "f:\data_model\book_data\test1.txt";
Filename fileref
Filename fileref
Eg:
发送程序运行结果到email
filename outbox email
ods html body=outbox ;
title 'Here is title';
proc print data=sashelp.class;
run;
ods html close;
发送带附件的email
ods listing close;
ods html
file='test.html';
proc univariate data=sashelp.class;
class sex;
var weight;
histogram;
run;
ods html close;
ods listing;
filename outbox email ("name1@company.com" "name2@company.com");
data _null_;
run;
抓取某个网页的源代码:
filename ws url "http://www.sas.com";
data sas;
infile ws length=len lrecl=4000;;
input record $varying4000. len;
run;
3.include语句
%include "f:\data_model\test1.txt";
Eg:一次调入多个sas程序
filename sasf "f:\data_model\book_data\chapt8\";
%include sasf(inc.sas,inc2.sas);