sas >> How to email a data set, report, tabulate

by sas9bi » Tue, 08 Apr 2008 12:32:14 GMT

Hi all, I googled the above topic and was confused and didnt find a solution
that a newbie like me could follow. All I need to do is email a dataset as
a excel file or a pdf or html that I created in base SAS. I know I can
leave SAS, go into Outlook, attach the file that ODS created, look up staff
to email file to, then send. I want something all in one inside SAS. Is
this possible?

My company uses Outlook and this solution needs to support SAS 8.2.

Any suggestions on doing this easily using a PROC or something like that?

Thanks in advance for any input, as I am a mere novice who barely knows
anything (but trying hard to be like you all!)

sas >> How to email a data set, report, tabulate

by RolandRB » Tue, 08 Apr 2008 13:36:08 GMT



Have they got sas at the other end? If so, then send them the actual
dataset.

sas >> How to email a data set, report, tabulate

by patho » Tue, 08 Apr 2008 16:11:25 GMT


Hi,

a quick search in my code give me the following partial code
you can send ODS html as the email body for outlook.

regards,

Mark Roosen



/* get the work location directory */
proc sql noprint;
select path into: workloc
from sashelp.vlibnam
where libname EQ 'WORK';
quit;
%let workloc = &workloc;
%put &workloc;

filename outfile email
subject= "newsgroup posting test"
from = " XXXX@XXXXX.COM "
to = " XXXX@XXXXX.COM "
type = "text/html";
/*attach ="&workloc/&suppl..xls"*/


ods html body=outfile ;

title "Males class email";
proc print data=sashelp.class noobs;
var sex name;
where sex = 'M';
run;

title "Females";
proc print data=sashelp.class noobs;
var sex name;
where sex = 'F';
run;

ods html close;
ods listing;

sas >> How to email a data set, report, tabulate

by michaelraithel » Tue, 08 Apr 2008 20:29:55 GMT

Dear SAS-L-ers,

sas 9 bi posted the following:

sas 9 bi, google; schmoogle! The best place to look for such topics is
in the SAS conference papers via Lex Jansen's fabulous web facility:

http://www.lexjansen.com/

There is a reasonable paper on this in the SAS Global Forum 2008
proceedings:

Sending E-mail from the DATA step, by Erik W. Tilanus,
http://www2.sas.com/proceedings/forum2008/038-2008.pdf

...and several from the "last" SUGI:

Batch Job to Create and Send Mass Excel Reports Using REXX, SAS,
HTML(XML) and Email System, By Stanislaw Furdal
http://www2.sas.com/proceedings/sugi31/021-31.pdf

You've Got E-Mail: Automatic Log Checking Via E-mail Notification, By
Augustine and Dutta
http://www2.sas.com/proceedings/sugi31/128-31.pdf

E-mail from your SAS(r) Session: How and Why, By David H. Johnson
http://www2.sas.com/proceedings/sugi31/256-31.pdf

Check them out; they may give flesh out your knowledge of what is
capable with sending emails via SAS.

sas 9 bi, best of luck in all of your SAS email endeavors!


I hope that this suggestion proves helpful now, and in the future!

Of course, all of these opinions and insights are my own, and do not
reflect those of my organization or my associates. All SAS code and/or
methodologies specified in this posting are for illustrative purposes
only and no warranty is stated or implied as to their accuracy or
applicability. People deciding to use information in this posting do so
at their own risk.

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Michael A. Raithel
"The man who wrote the book on performance"
E-mail: XXXX@XXXXX.COM

Author: Tuning SAS Applications in the MVS Environment

Author: Tuning SAS Applications in the OS/390 and z/OS Environments,
Second Edition
http://www.sas.com/apps/pubscat/bookdetails.jsp?catid=1&pc=58172

Author: The Complete Guide to SAS Indexes
http://www.sas.com/apps/pubscat/bookdetails.jsp?catid=1&pc=60409

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Crooks are early adopters. - Craig Newmark
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

sas >> How to email a data set, report, tabulate

by mc » Tue, 08 Apr 2008 21:26:39 GMT

Hi!

The following explains pretty well how to automate mails from SAS.

http://sausag.sasusers.net/presentations/0505Emailing %20From%20SAS.ppt

sas >> How to email a data set, report, tabulate

by richard.wright » Tue, 08 Apr 2008 22:03:03 GMT

Here's something I wrote that emailed reports. The names have been changed
to protect the guilty, but otherwise worked (under 8.2 as well as later -
well the ods might have changed - and went to outlook.)

PROC SQL NOPRINT;
CREATE TABLE miss_eid AS
SELECT DISTINCT emplid FROM e_dist EXCEPT CORR
(SELECT emplid FROM sasuser.emp UNION CORR SELECT emplid
FROM sasuser.job_hist_upd);
CREATE TABLE miss_pos AS
SELECT DISTINCT position_nbr FROM e_dist EXCEPT CORR
(SELECT position_nbr FROM sasuser.emp UNION CORR SELECT
position_nbr FROM sasuser.job_hist_upd);
CREATE TABLE miss_name AS
SELECT DISTINCT emplid FROM select_emp
WHERE Trimn(last_name) = ' ' AND Trimn(first_name) = ' ';
SELECT Count(DISTINCT emplid) INTO :meid FROM miss_eid;
SELECT Count(DISTINCT position_nbr) INTO :mpos FROM miss_pos;
SELECT Count(DISTINCT emplid) INTO :meidb FROM miss_name;
QUIT;

/*
DM 'VT miss_eid' VT ;
DM 'VT miss_pos' VT ;
*/

ODS NORESULTS;
ODS RTF FILE= 'C:\Documents and Settings\WRIG7821\My Documents\My SAS
Projects\xxx-proj\Reports\data_request.doc';
TITLE "Missing Employee Information";
PROC PRINT DATA=miss_eid; RUN;
TITLE "Missing Position History";
PROC PRINT DATA=miss_pos; RUN;
TITLE "Missing Employee Name";
PROC PRINT DATA=miss_name; RUN;
TITLE;

ODS RTF CLOSE;
ODS RESULTS;

FILENAME em EMAIL 'nul';

DATA _null_;
RETAIN fdate &mboperiod meid &meid mpos &mpos meidb &meidb;
ldate = Today();
FILE em COLUMN=c
TO = " XXXX@XXXXX.COM "
CC = " XXXX@XXXXX.COM "
SUBJECT = "Data Request"
ATTACH = ("C:\Documents and Settings\WRIG7821\My
Documents\My SAS Projects\xxx-proj\Reports\data_request.doc")
;

PUT '!EM_NEWMSG!';
PUT 'Jose:' //
"Here's something I need" /
"From " fdate WORDDATE12. -l " To Current (" ldate
WORDDATE12. -l ")" // ;
IF (Sum(&meid, &mpos, 0) > 0) THEN PUT "For your guidance, I use
the following queries:" /;
IF meid > 0 THEN
PUT
"SELECT A.EMPLID, A.DEPTID, A.POSITION_NBR, A.REPORTS_TO,
A.FULL_PART_TIME, A.JOB_ENTRY_DT, A.POSN_CHANGE_RECORD," /
@10 "A.EFFDT, A.ACTION_DT, A.ACTION, A.ACTION_REASON,
A.EFFSEQ" /
@5 "FROM PS_JOB A, PS_EMPLMT_SRCH_QRY A1" /
@5 "WHERE A.EMPLID = A1.EMPLID" /
@5 "AND A.EMPL_RCD = A1.EMPL_RCD" /
@5 "AND A1.ROWSECCLASS = 'DPWALL'" //;

IF mpos > 0 THEN
PUT "SELECT A.EMPLID, A.NATIONAL_ID AS ssn" /
@5 "FROM PS_PERSONNEL A, PS_EMPLMT_SRCH_QRY A1" /
@5 "WHERE A.EMPLID = A1.EMPLID" /
@10 "AND A.EMPL_RCD = A1.EMPL_RCD" /
@10 "AND A1.ROWSECCLASS = 'DPWALL'" /
@10 "AND ( A.EFFDT =" /
@10 "(SELECT MAX(A_ED.EFFDT) FROM PS_PERSONNEL A_ED" /
@10 "WHERE A.EMPLID = A_ED.EMPLID" /
@10 "AND A.EMPL_RCD = A_ED.EMPL_RCD" /
@10 "AND A_ED.EFFDT <= SYSDATE)" /
@10 "AND A.EFFSEQ =" /
@10 "(SELECT MAX(A_ES.EFFSEQ) FROM PS_PERSONNEL A_ES" /
@10 "WHERE A.EMPLID = A_ES.EMPLID" /
@10 "AND A.EMPL_RCD = A_ES.EMPL_RCD" /
@10 "AND A.EFFDT = A_ES.EFFDT) )" //;

IF meidb > 0 THEN
PUT "I get this from HHSAS: SELECT A.EMPLID, A.NAME FROM
PS_PERSONAL_DATA A";

PUT ' ';

PUT "If you need authorization, " /
"please contact Somebody Else at 332-4601, or
XXXX@XXXXX.COM ";

PUT ' ';

PUT "Thank You," / "Richard Wright" / "332-4671";

PUT ' ';

IF (Sum(&meid, &mpos, &meidb, 0) > 0) THEN PUT '!EM_SEND!';
PUT '!EM_ABORT!';
STOP;
RUN;

FILENAME em;

sas >> How to email a data set, report, tabulate

by sas9bi » Tue, 08 Apr 2008 22:50:46 GMT

On Mon, 7 Apr 2008 22:36:08 -0700, RolandRB < XXXX@XXXXX.COM >



solution
dataset as
staff
Is
that?

RolandRB - The recipients of my email do not have SAS on their machines.
I want an easy way to have SAS send them an email with an attached excel
or some other type of output using base SAS. Thanks!

sas >> How to email a data set, report, tabulate

by gerhard.hellriegel » Tue, 08 Apr 2008 23:26:02 GMT

Ok, I try it. That is a example from KfW in Germany, you could adapt. It
is a CSV file and a GIF graph. It is produced on zOS, therefor I cannot
use a binary EXCEL file. If you are on Win, that should be no problem.

DATA _NULL_;
ppp="('"!!"&lpath.' "!!
" name=&mnam.' "!!
" type='text/plain'"!!
" ext='csv' '"!!
"&gpath."!!
"' name=&mnam.' "!!
" type='image/gif'"!!
" ext='gif' ) ";
CALL SYMPUT('DAT',ppp);
put ppp=;
CALL SYMPUT('MAIL', '(" XXXX@XXXXX.COM "
RUN;

FILENAME MYMAIL EMAIL &MAIL
SUBJECT="KIS Job Ressourcen vom &ended"
FROM="& XXXX@XXXXX.COM "
SENDER="& XXXX@XXXXX.COM "
ATTACH=&DAT;

DATA _NULL_;
FILE MYMAIL;
PUT "Sehr geehrte Damen und Herren,";
PUT " " ;
PUT "im Anhang finden Sie die Auswertung";
PUT "fuer KIS Job-Verbraeuche vom &startd &startt Uhr";
PUT "bis &ended &endet Uhr als CSV Datei";
put " und eine Trendgrafik von &strtdat bis &enddat";
PUT " ";
PUT "Diese Mail wurde automatisch erstellt. Bitte ";
PUT "nicht antworten!";
PUT " ";
PUT " ";
PUT "Mit freundlichem Gruss";
PUT "Ihr KIS";
RUN;

######################################################

From the SAS documentation, another simple example:

filename mymail email " XXXX@XXXXX.COM "
subject="a EXCEL file"
attach="/u/sas/test.xls";

data _null_;
file mymail;
put 'Jim,';
put 'This is my EXCEL file.';
put 'I think you might like it';
run;

If you don't fill the TYPE parameter, SAS will try to detect the right one
from the extension of your file.

That all uses the SMTP protocol.

Try it out, it is easy.
Gerhard

sas >> How to email a data set, report, tabulate

by sas9bi » Wed, 09 Apr 2008 00:05:36 GMT

erhard - Excellent!!! This worked so easily!!!

filename mymail email " XXXX@XXXXX.COM "
subject="a EXCEL file"
attach="/u/sas/test.xls";

data _null_;
file mymail;
put 'Jim,';
put 'This is my EXCEL file.';
put 'I think you might like it';
run;




On Tue, 8 Apr 2008 11:26:02 -0400, Gerhard Hellriegel
< XXXX@XXXXX.COM > wrote:

can
knows

Similar Threads

1. How to set two data sets but only keep variables in the first data set

Hi All,

I have two data sets, each one has more than 200 variables (some of
them are same, some are not). I wanna keep all variables of the first
data set.
How do I set two data sets but only keep those variables in the first
data set? I cannot use keep= or drop= option since there are too many
variables. 

Thanks a lot,
Pooh

2. Conditional Reporting (one for data and Other Empty data set

3. Tabulate to an output data set

Hi all,

I have been requested to create and present a short presentation on
creating output data set from a proc tabulate.  This would ideally
entail the how to, the why you would need to and the benefits that can
be gained by doing this.  The problem is that at the moment, I have
drawn a complete blank as to all of these questions with the exception
of the how using the out = option, or the ods output options, but that
option is all that I can find and it only creates a standard data set
output.  I have no idea as to whether it can be refined or manipulated
in any way using other options.   Is there anything more that can be
done other than just simply outputting a standard data set, or am I
flogging a dead horse?

Any help would be gratefully appreciated.

Many thanks for your time,

Rob Walls.

_______________________________________________________
This e-mail transmission and any documents, files or previous email messages attached to it may contain information that is confidential or legally privileged. If you are not the intended recipient or a person responsible for delivering this transmission to the intended recipient, you are hereby notified that you must not read this transmission and that any disclosure, copying, printing, distribution or use of this transmission is strictly prohibited. If you have received this transmission in error, please immediately notify the sender by telephone or return email and delete the original transmission and its attachments without reading or saving in any manner.

4. PROC TABULATE - Class level variables in CLASSDATA data set

5. help needed for reporting using tabulate/ report

Hi,
 I need some assistance in creating tabulate reports. Even a sample pseudo
code will help me get started.........thanks in advance......

hari

>>>>>>>>>>>>>>>>>>>>>>>>>

Data Have ;
   input etype $ NoOfEvents NetLoss GrossLoss Recoveries;
   cards ;
        EL1    2   31.375    31.375     .
        EL2  356  691.088  1268.643  346.173
        EL3    1    5.602     5.602     .
        EL4    9  201.765   201.765     .
        EL5   13   35.376    35.376     .
        EL7  110  584.156   769.556  121.045
   ;
run ;

>>>>>>>>>>>final report>>>>>>>>>>>>>>

     operational losses and recoveries > $1000
EventType                1Q06
    GrossLoss  Recoveries NetLoss   # of events
EL1     $31,375        $0 $31,375      2
EL2  $1,268,643   $346,173      $691,088    356
EL3      $5,602        $0  $5,602      1
EL4    $201,765        $0      $201,765      9
EL5         $35,376        $0       $35,376     13
EL6      $0        $0      $0      0
EL7        $769,556      $121,045      $584,156    110

6. help needed for reporting using tabulate/ report - modified

7. Update info in data set based on other data set

Hi
I have a problem as follows :
I want to create a dataset C that copies all of data set A
as well as adds an additional variable (varx) as 0/1 based on whether an
observation id in dataset A occurs in dataset B (on the same date).
I have tried a PROC SQL as follows but with no success:

proc sql ;
create table c as
select a.*,
case when a.id=b.id and a.date=b.date
      then 0
      else 1
end as varx
from datasetA as a, datasetB as b;
quit;

I get a timeout (OUT OF RESOURCES error).
Any idea on what I am doing wrong here?

8. VIEWTABLE: Display Data Set Name Instead of Data Set Label