SAS Email - Linux Platform
2016-02-26 13:49
896 查看
%macro auto_email; %let file='/mnt/projects/public/offshore_office/yyliang/yinna.txt'; /*%let file ='\\Hqdellsas04\exports\APJ\yinna.txt';*/ LIBNAME smb_prod odbc dsn='HQDELLNZ06_SMB_SANDBOX' user=yyliang pwd=123 schema=dbo; /*LIBNAME smb_prod NETEZZA DATABASE=smb_sandbox SERVER=hqdellnz06 AUTHDOMAIN="hqdellnz06" user=yyliang pwd=<span style="font-family: Arial, Helvetica, sans-serif;">123 </span>DBCONINIT='SET SERIALIZABLE = FALSE;' */ filename myfile &file.; %if %sysfunc(fexist(myfile)) %then %do; %put File Exist; %put %sysfunc(fdelete(myfile)); %put File deleted; %end; %else %put File not exist.; proc export data=smb_prod.tmp_sas_email_2 outfile=&file. DBMS=DLM; delimiter='|'; run; data temp; infile &file. MISSOVER DSD lrecl=60000 firstobs=2 delimiter='|' encoding=utf8 ; input CVMID:$20. companyname:$200. accounttype:$200. priority:$200. recommend:$200. purchase_history:$200. email:$100. ; label companyname="公司名称" accounttype="账户属性" priority="优先级" recommend="推荐产品" purchase_history="曾购产品"; run; /*proc print data=temp label obs="序号"; run;*/ %if %sysfunc(fexist(myfile)) %then %do; %put File Exist; %put %sysfunc(fdelete(myfile)); %put File deleted; %end; %else %put File not exist.; proc sql errorstop; select count(distinct email) into :email_cnt from temp where email <>'' ; select distinct email into :email_list separated by ' ' from temp where email<>'' ; quit; %put email_cnt is : &email_cnt.; %put email_list: &email_list.; %do i=1 %to &email_cnt.; %let email_addr= %scan( &email_list. , &i., %str(' ') ); %put email_addr is : &email_addr.; proc sql errorstop; create table temp_email as select CVMID, companyname, accounttype, priority, recommend, purchase_history from temp where email= "&email_addr"; quit; data _null_; set temp_email nobs=nobs; call symputx("nobs", nobs); stop; run; %put nobs= &nobs.; %put There are &nobs. account(s) in the email &email_addr.; Data _null_; format GDC_time time9.; GDC_time=intnx("second", time(), -gmtoff()); GDC_time=intnx("min", GDC_time, 60*8); if (GDC_time>24*3600) then do; put "Bigger then 24 hours"; GDC_time=intnx("min", GDC_time, -24*60); GDC_date=date()+1; end; else do; put "Lower than 24"; GDC_date=date(); end; call symput('GDC_date', put(GDC_date, yymmdd10.)); call symput('GDC_time', put(GDC_time, time9.)); run; ODS HTML BODY=output STYLE=Sasweb; TITLE JUSTIFY=left "<head><font size=4> Dear Sir/Madam, 本周内您需要联系维护的客户信息如下: </head> <body><br></body> <body><font size=2> 请注意,本次邮件内容仅为测试数据,请勿做任何商业使用。谢谢合作 </body> <body><font size=2> 如有任何问题,请联系 Tony Zhu (Tony_zhu2@Dell.com), Sophie Zhang(sszhang@merkleinc.com)。 </body> <br> <body><font size=2> 本次邮件发送时间: &GDC_date. &GDC_time. </body> "; proc print data=temp_email label obs="序号"; run; ODS HTML CLOSE; filename output EMAIL sender=("wzhao@merkleinc.com") to=("&email_addr.") subject='D&R Account 联系维护客户名单 - 测试邮件' ct='text/html' encoding=UTF8; %end; %mend; %auto_email;
相关文章推荐
- linux设备驱动归纳总结(七):2.内核定时器
- linux设备驱动归纳总结(七):1.时间管理与内核延时
- Linux出现Read-only file system错误的解决方法
- Linux主机上发布java web应用
- 轻量级 Linux下ssh破解工具
- Linux历史相关习题及答案
- Linux下nfs实现跨机器的文件共享(个人项目经验)
- Linux动态库的编译与使用 转载
- 刚装好的linux系统如何获取root的权限
- 使用 linux-dnw 给S5PV210烧录裸机程序
- CentOS 6、7下配置exim发邮件服务器
- 鸟哥的Linux私房菜(服务器)- 主机基本安全之二: Linux线上自动升級
- 鸟哥的Linux私房菜(服务器)- 主机基本安全之一:限制 Linux 对外连线的端口
- 鸟哥的Linux私房菜(服务器)- 架站文件習題解答篇
- 鸟哥的Linux私房菜(服务器)- 簡易 Cluster 架設
- kali linux aircrack-ng 破解wifi 使用记录
- 鸟哥的Linux私房菜(服务器)- 簡易 APT/YUM 伺服器設定
- 鸟哥的Linux私房菜(服务器)- 第二十二章、邮件服务器: Postfix
- 鸟哥的Linux私房菜(服务器)- 第二十一章、文件服务器之三: FTP 服务器
- 鸟哥的Linux私房菜(服务器)- 第二十章、WWW 伺服器