PUT "!EM_TO!" "joe@somplace.org";
PUT "!EM_TO!" ('joe@smplc.org' 'jane@diffplc.org');
PUT "!EM_CC!" "joe@somplace.org";
PUT "!EM_CC!" ('joe@smplc.org' 'jane@diffplc.org');
PUT "!EM_BCC!" "joe@somplace.org";
PUT "!EM_BCC!" ('joe@smplc.org' 'jane@diffplc.org');
put '!EM_ATTACH!' "('user.misc.pds(member)' content_type='text/html' extension='html')"; put '!EM_ATTACH!' "('user.misc.jcl(sasjcl)' extension='doc', 'userid.sas.output' content_type='image/gif' extension='gif' name='Test Results')"; mycfg="'user.misc.jcl(sasjcl)'"; syscfg="'user.sas.output' content_type='image/gif' ext='gif'"; put '!EM_ATTACH!' "("mycfg","syscfg")";
filename mymail email 'JBrown@ajax.com' subject='My SASV9 CONFIG file' attach="jbrown.tso.config(sasV9)"; data _null_; file mymail; put 'Jim,'; put 'This is my SASV9 CONFIG file.'; put 'I think you might like the new options I added.'; run;
filename outbox email 'ron@acme.com'; data _null_; file outbox to=('ron@acme.com' 'lisa@acme.com') /* Overrides value in */ /* filename statement */ cc=('margaret@yourcomp.com' 'lenny@laverne.abc.com') subject='My SAS output' attach=("my.sas.output" "my.sas.code") ; put 'Folks,'; put 'Attached is my output from the SAS program I ran last night.'; put 'It worked great!'; run;
filename reports email 'Jim@corp.com'; data _null_; file reports; infile cards eof=lastobs; length name dept $ 21; input name dept; put '!EM_TO!' name; /* Assign the TO attribute */ put '!EM_SUBJECT! Report for ' dept; /* Assign the SUBJECT attribute */ put name ','; put 'Here is the latest report for ' dept '.'; if dept='marketing' then put '!EM_ATTACH!' "userid.market.report"; else /* ATTACH the appropriate report */ put '!EM_ATTACH!' "userid.devlpmnt.report"; put '!EM_SEND!'; /* Send the message */ put '!EM_NEWMSG!'; /* Clear the message attributes */ return; lastobs: put '!EM_ABORT!'; /* Abort the message before the */ /* RUN statement causes it to */ /* be sent again. */ datalines; Susan marketing Jim marketing Rita development Herb development ; run;
filename outbox email to='susan@mvs' type='text/html' subject='Temperature conversions' ; data temperatures; do centigrade = -40 to 100 by 10; fahrenheit = centigrade*9/5+32; output; end; run; ods html body=outbox /* Mail it! */ rs=none; title 'Centigrade to Fahrenheit conversion table'; proc print; id centigrade; var fahrenheit; run; ods html close;
filename gsasfile email to='Jim@acme.com' type='image/gif' subject="SAS/GRAPH output." ; goptions dev=gif gsfname=gsasfile; proc gtestit pic=1; run;
/* ---------------------------------------- */ /* allocate PDSE to contain the HTML output */ /* ---------------------------------------- */ filename odsout '.mvsmail1.pdse' disp=(new,catlg,delete) dsorg=po dsntype=library; /* ------------------------------------ */ /* stop sending output to OUTPUT window */ /* ------------------------------------ */ ods listing close; /* ----------------------------------------------------- */ /* Assign frame, contents and body files. */ /* Specify the URLs to have the .html extension. */ /* Specify the PATH to be the PDSE. */ /* Specify RS=NONE to write one line of HTML per record. */ /* This is necessary when e-mailing the HTML output. */ /* ----------------------------------------------------- */ ods html frame='shoes1f' contents='shoes1c' (url='shoes1c.html') body='shoes1b' (url='shoes1b.html') path=odsout rs=none; data newshoes; set sashelp.shoes; where Region in ('Canada' 'Central America/Caribbean' 'South America' 'United States'); run; /* ----------------------------------------- */ /* sort the data set and generate the report */ /* ----------------------------------------- */ proc sort data=newshoes; by Region Subsidiary Product; run; options nobyline; title1 'Sales for Regions #byval(Region)'; proc report data=newshoes nowindows; by Region; column Region Product Subsidiary Sales; define Region / noprint group; define Product / display group; define Subsidiary / display group; define Sales / display sum format=dollar8.; compute after Region; Product='Total'; endcomp; break after Region / summarize style=rowheader; run; /* ------------------------------------------------------ */ /* Close the HTML destination and open the listing output */ /* ------------------------------------------------------ */ ods html close; ods listing; /* ----------------- */ /* E-mail the report */ /* ----------------- */ filename email email 'fred@bedrock.com' subject="Shoe report 1" type="text/plain" attach=(".mvsmail1.pdse(shoes1f)" content_type='text/html' extension='html' ".mvsmail1.pdse(shoes1c)" content_type='text/html' extension='html' ".mvsmail1.pdse(shoes1b)" content_type='text/html' extension='html') ; data _null_; file email; put 'Here is the latest Shoe sales report'; run;
/* ------------------------------------------------ */ /* Define the UNIX System Services USS directory to */ /* contain the graphics and HTML output. */ /* ------------------------------------------------ */ filename odsout '/u/myhome/public_html'; /* ------------------------------------------------ */ /* stops sending output to GRAPH and OUTPUT windows */ /* ------------------------------------------------ */ ods listing close; /* ---------------------------- */ /* set the graphics environment */ /* ---------------------------- */ goptions reset=global gunit=pct colors=(black blue green red) hsize=8.42 in vsize=6.31 in ftitle=zapfb ftext=swiss htitle=4 htext=2.5 device=gif transparency noborder; /* --------------------------------- */ /* add the HTML variable to NEWSHOES */ /* --------------------------------- */ data newshoes; set sashelp.shoes; where Region in ('Canada' 'Central America/Caribbean' 'South America' 'United States'); length regdrill $40; if Region='Canada' then regdrill='HREF="shoes1_regsales.html#IDX1"'; else if Region='Central America/Caribbean' then regdrill='HREF="shoes1_regsales.html#IDX2"'; else if Region='South America' then regdrill='HREF="shoes1_regsales.html#IDX3"'; else if Region='United States' then regdrill='HREF="shoes1_regsales.html#IDX4"'; run; /* ------------------------------------------------------*/ /* Assign the destination for the ODS graphics output */ /* and ODS HTML files. */ /* Specify RS=NONE to write one line of HTML per record. */ /* This is necessary when e-mailing the HTML output. */ /* ----------------------------------------------------- */ ods html path=odsout body='shoe_report.html' rs=none nogtitle; /* ----------------------------------- */ /* define title and footnote for chart */ /* ----------------------------------- */ title1 'Total Sales for the Americas'; footnote1 h=3 j=l 'click on bars' j=r 'REPORT3D '; /* ----------------------------------- */ /* assign a pattern color for all bars */ /* ----------------------------------- */ pattern color=cyan; /* --------------------------- */ /* define axis characteristics */ /* --------------------------- */ axis1 order=(0 to 7000000 by 1000000) minor=(number=1) label=none; axis2 label=none offset=(4,4) value=('Canada' 'C. Amr./Car.' 'S. America' 'USA'); /* --------------------------- */ /* generate vertical bar chart */ /* --------------------------- */ proc gchart data=newshoes; vbar3d Region / discrete width=6 sumvar=sales html=regdrill coutline=black cframe=blue maxis=axis2 raxis=axis1 name='shoes1 '; run; quit; /* ----------------------------------------------------- */ /* Open the HTML destination for the PROC PRINT output. */ /* Specify RS=NONE to write one line of HTML per record. */ /* This is necessary when e-mailing the HTML output. */ /* ----------------------------------------------------- */ ods html body='shoes1_regsales.html' rs=none path=odsout; /* ----------------------------------------- */ /* sort data set NEWSHOES in order by region */ /* ----------------------------------------- */ proc sort data=newshoes; by Region Subsidiary Product; run; quit; /* -------------------------------------------- */ /* print a report of shoe sales for each Region */ /* -------------------------------------------- */ goptions reset=footnote; option nobyline; title 'Sales Report for #byval(Region)'; proc report data=newshoes nowindows; by Region; column Region Subsidiary Product Sales; define Region / noprint group; define Subsidiary / display group; define Product / display group; define Sales / display sum format=dollar12.; compute after Region; Subsidiary='Total'; endcomp; break after Region / summarize style=rowheader page; run; /* ------------------------------------------------------ */ /* Close the HTML destination and open the listing output */ /* ------------------------------------------------------ */ ods html close; ods listing; /* ---------------- */ /* Email the report */ /* -----------------*/ filename email email 'barney@bedrock.com' subject="Shoe report 2" type="text/plain" attach=("./public_html/shoe_report.html" content_type='text/html' "./public_html/shoes1_regsales.html" content_type='text/html' "./public_html/shoes1.gif" content_type='image/gif') ; data _null_; file email; put 'Here is the latest Shoe sales report'; run;
/* STEP 1 */ data printers; name = 'emailjoe'; protocol = 'Ascii'; trantab = 'GTABCMS'; model = 'PostScript Level 1 (Gray Scale)'; device = 'EMAIL'; dest = 'John.Doe@sas.com'; hostopt = "recfm=vb ct='application/PostScript' subject='Canada Report' "; run; /* STEP 2 */ proc prtdef data=printers replace list; run;
send:
label) to execute. send: /* set up a fileref */ rc = filename('mailit','userid','email'); /* if the fileref was successfully set up open the file to write to */ if rc = 0 then do; fid = fopen('mailit','o'); if fid > 0 then do; /* fput statements are used to implement writing the mail and the components such as subject, who to mail to, etc. */ fputrc1 = fput(fid,line1); rc = fwrite(fid); fputrc2 = fput(fid,'!EM_TO! '||mailto); rc = fwrite(fid); fputrc3 = fput(fid,'!EM_CC! '||copyto); rc = fwrite(fid); fputrc4 = fput(fid,'!EM_ATTACH! '||attach); rc = fwrite(fid); fputrc5 = fput(fid,'!EM_SUBJECT! '||subject); rc = fwrite(fid); closerc = fclose(fid); end; end; return; cancel: call execcmd('end'); return;