View previous topic :: View next topic
|
Author |
Message |
sakrat
Active User
Joined: 05 Feb 2014 Posts: 164 Location: India
|
|
|
|
I used SAS in sending the Mail, Now I am getting all the fields in the CSV file....Thanks all for your help.... |
|
Back to top |
|
|
vasanthz
Global Moderator
Joined: 28 Aug 2007 Posts: 1742 Location: Tirupur, India
|
|
|
|
Yes, using SAS mail is the optimal way when you already have SAS installed at your shop. SAS mail handles CSV,HTML,EXE,PDF,DOC and many other file types correctly without much jumping through the hoops.
It is like searching for ghee when you have vennai in your hand :-) |
|
Back to top |
|
|
sakrat
Active User
Joined: 05 Feb 2014 Posts: 164 Location: India
|
|
|
|
One last doubt can we format the record when sending as csv file like I want the header row to have different background color and in Bold. is it possible to do that..... |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
If what you are sending the data two has a "markup" language, then yes. Just include the markup codes and the receiver will get the formatted output. |
|
Back to top |
|
|
vasanthz
Global Moderator
Joined: 28 Aug 2007 Posts: 1742 Location: Tirupur, India
|
|
|
|
Quote: |
One last doubt can we format the record when sending as csv file like I want the header row to have different background color and in Bold. |
It is 'un'possible to have formatting with ODS CSV.
Use something like ODS HTML while creating output file.
Code: |
ODS LISTING CLOSE;
ODS HTML FILE='some VB PS file' style=sasweb rs=none;
proc print ...
..
run;
ODS HTML CLOSE;
ODS LISTING; |
STYLE=SASWEB or MINIMAL or anything else
STYLE element gives a predefined style. If you need customized styles you may need to use PROC TEMPLATE to edit the styles. |
|
Back to top |
|
|
sakrat
Active User
Joined: 05 Feb 2014 Posts: 164 Location: India
|
|
|
|
vasanthz wrote: |
Quote: |
One last doubt can we format the record when sending as csv file like I want the header row to have different background color and in Bold. |
It is 'un'possible to have formatting with ODS CSV.
Use something like ODS HTML while creating output file.
Code: |
ODS LISTING CLOSE;
ODS HTML FILE='some VB PS file' style=sasweb rs=none;
proc print ...
..
run;
ODS HTML CLOSE;
ODS LISTING; |
STYLE=SASWEB or MINIMAL or anything else
STYLE element gives a predefined style. If you need customized styles you may need to use PROC TEMPLATE to edit the styles. |
Actually I have detailed records in one ps file and the header record in one ps file.
The PS file containing the detailed records is processed from the SAS code which I have shown earlier in the above link provided.
The header record is just a normal PS file written manually with comma separated format.
I use SORT fields=copy and merge the above two dataset, then use one more SAS code to send mail of the resultant dataset.
Can I use the formats which you have mentioned in the SAS code that which sends mail....? |
|
Back to top |
|
|
sakrat
Active User
Joined: 05 Feb 2014 Posts: 164 Location: India
|
|
|
|
sakrat wrote: |
vasanthz wrote: |
Quote: |
One last doubt can we format the record when sending as csv file like I want the header row to have different background color and in Bold. |
It is 'un'possible to have formatting with ODS CSV.
Use something like ODS HTML while creating output file.
Code: |
ODS LISTING CLOSE;
ODS HTML FILE='some VB PS file' style=sasweb rs=none;
proc print ...
..
run;
ODS HTML CLOSE;
ODS LISTING; |
STYLE=SASWEB or MINIMAL or anything else
STYLE element gives a predefined style. If you need customized styles you may need to use PROC TEMPLATE to edit the styles. |
Actually I have detailed records in one ps file and the header record in one ps file.
The PS file containing the detailed records is processed from the SAS code which I have shown earlier in the above link provided.
The header record is just a normal PS file written manually with comma separated format.
I use SORT fields=copy and merge the above two dataset, then use one more SAS code to send mail of the resultant dataset.
Can I use the formats which you have mentioned in the SAS code that which sends mail....? |
So here is my code below where I have concatenated the detailed record and the Header record:
Code: |
//FNDRPLCE EXEC PGM=SORT
//SORTIN DD DSN=***.CNTRLM.HEADER,DISP=SHR
// DD DSN=&&TEMP4,DISP=SHR
//SORTOUT DD DSN=***.***.FINAL.CNTRLM.RPT,
// DISP=(NEW,CATLG,DELETE),
// UNIT=PERMDA,
// SPACE=(TRK,(7500,7500),RLSE),
// DCB=(RECFM=FB,LRECL=1202,BLKSIZE=0)
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
OUTREC FINDREP=(INOUT=(C'Q07',C'PRE',C'TRE',C'PRE'))
/*
|
***.CNTRLM.HEADER is the dataset that contains header with comma separated format
&&TEMP4 contains the detailed records.
Both are concatenated and put in the =***.***.FINAL.CNTRLM.RPT dataset.
below is the next step which sends mail in CSV format :
Code: |
//SENDMAIL EXEC SAS,
// WORK='500,500',
// OPTIONS='SORTWKNO=3 SORT=500'
//MAILADDR DD DSN=***.***.CNTRL.EMAIL,DISP=SHR
//SYSIN DD *
FILENAME EMAIL EMAIL LRECL=503 RECFM=VB;
DATA NAMES;
INFILE MAILADDR;
INPUT
@001 NAME $CHAR60.
;
DATA _NULL_;
FILE EMAIL;
SET NAMES END=LAST;
LENGTH FIRSTNAME $20;
FIRSTNAME=SCAN(NAME,1,'.');
RETAIN FROMNAME ***@***.COM';
PUT '!EM_FROM!' FROMNAME;
PUT '!EM_TO!' NAME;
PUT '!EM_SUBJECT! sub name;
PUT 'Hi, ';
PUT ' ';
PUT 'PLEASE FIND ATTACHED.';
PUT '!EM_ATTACH!' "(***.***.FINAL.CNTRLM.RPT'
NAME='CONTROL-M DOCUMENT' CONTENT_TYPE='TEXT/CSV' EXT='CSV' )";
PUT ' ';
PUT '*************************************************************';
PUT 'Note : Please do not respond to this mail. ';
PUT 'It is automatically generated from an unattended Mailbox. ';
PUT '*************************************************************';
PUT '!EM_SEND!';
PUT '!EM_NEWMSG!';
IF LAST THEN PUT '!EM_ABORT!';
;
RUN;
/*
|
So where can I use the formatting in these two steps so that the header is highlighed. |
|
Back to top |
|
|
vasanthz
Global Moderator
Joined: 28 Aug 2007 Posts: 1742 Location: Tirupur, India
|
|
|
|
Hello,
It all seems to make sense now..
Did not knew that the previous post was related to this one.
As I understand, now you are writing the required output to a dataset via the put statement: You are manually generating a CSV file.
Code: |
PUT
@1 CHNGTYPE $3.
@4 C $1.
@5 JBNAME $8.
.
.
. |
A better and easier solution would be, just comment out the PUT statement altogether & don't write the CSV file to a PS file.
Have this step after the DATA step. This code basically creates a XML formatted file similar to the PUT statement & writes it to a PS file WELLS.PS.FILE.LRECL-10000.RECFM-VB
Code: |
ODS LISTING CLOSE;
ODS MSOFFICE2K FILE='WELLS.PS.FILE.LRECL-10000.RECFM-VB' STYLE=NORMAL RS=NONE;
PROC PRINT DATA = FILE2 NOOBS;
RUN;
ODS MSOFFICE2K CLOSE;
ODS LISTING;
|
After this step Have a SAS email step like the one below. This step emails the XML file WELLS.PS.FILE.LRECL-10000.RECFM-VB.
Code: |
//emailstep EXEC SAS
//HTMLOUT DD DSN=WELLS.PS.FILE.LRECL-10000.RECFM-VB,DISP=SHR
//SYSIN DD *
FILENAME EMAIL EMAIL
FROM = ("wells@yolo.com")
TO = ("wells@yolo.com"
"wells2@yolo.com")
REPLYTO=("wells@yolo.com")
SUBJECT="This is a nice formatted instream email."
TYPE='TEXT/HTML';
DATA _NULL_;
FILE EMAIL;
INFILE HTMLOUT;
INPUT;
PUT _INFILE_;
RUN;
|
The above email step sends the report as instream email.
If you want the report as attachment, then there are small tunings on the EMAIL step with ATTACH keyword. |
|
Back to top |
|
|
sakrat
Active User
Joined: 05 Feb 2014 Posts: 164 Location: India
|
|
|
|
vasanthz wrote: |
Hello,
It all seems to make sense now..
Did not knew that the previous post was related to this one.
As I understand, now you are writing the required output to a dataset via the put statement: You are manually generating a CSV file.
Code: |
PUT
@1 CHNGTYPE $3.
@4 C $1.
@5 JBNAME $8.
.
.
. |
A better and easier solution would be, just comment out the PUT statement altogether & don't write the CSV file to a PS file.
Have this step after the DATA step. This code basically creates a XML formatted file similar to the PUT statement & writes it to a PS file WELLS.PS.FILE.LRECL-10000.RECFM-VB
Code: |
ODS LISTING CLOSE;
ODS MSOFFICE2K FILE='WELLS.PS.FILE.LRECL-10000.RECFM-VB' STYLE=NORMAL RS=NONE;
PROC PRINT DATA = FILE2 NOOBS;
RUN;
ODS MSOFFICE2K CLOSE;
ODS LISTING;
|
After this step Have a SAS email step like the one below. This step emails the XML file WELLS.PS.FILE.LRECL-10000.RECFM-VB.
Code: |
//emailstep EXEC SAS
//HTMLOUT DD DSN=WELLS.PS.FILE.LRECL-10000.RECFM-VB,DISP=SHR
//SYSIN DD *
FILENAME EMAIL EMAIL
FROM = ("wells@yolo.com")
TO = ("wells@yolo.com"
"wells2@yolo.com")
REPLYTO=("wells@yolo.com")
SUBJECT="This is a nice formatted instream email."
TYPE='TEXT/HTML';
DATA _NULL_;
FILE EMAIL;
INFILE HTMLOUT;
INPUT;
PUT _INFILE_;
RUN;
|
The above email step sends the report as instream email.
If you want the report as attachment, then there are small tunings on the EMAIL step with ATTACH keyword. |
What does MSOFFICE2K in the below line mean:
Code: |
ODS MSOFFICE2K FILE='WELLS.PS.FILE.LRECL-10000.RECFM-VB' STYLE=NORMAL RS=NONE;
|
Also in the Email step you have specified TYPE='TEXT/HTML' what does HTML mean here. is it relating to some webpage...? Also in the TO line can I specify a dataset containing the Email ID's obtained through REXX PANEL where the user specifies the email-id's to which the document has to be sent mail. can you show me how will the code in case of attachment..... |
|
Back to top |
|
|
sakrat
Active User
Joined: 05 Feb 2014 Posts: 164 Location: India
|
|
|
|
vasanthz wrote: |
Hello,
It all seems to make sense now..
Did not knew that the previous post was related to this one.
As I understand, now you are writing the required output to a dataset via the put statement: You are manually generating a CSV file.
Code: |
PUT
@1 CHNGTYPE $3.
@4 C $1.
@5 JBNAME $8.
.
.
. |
A better and easier solution would be, just comment out the PUT statement altogether & don't write the CSV file to a PS file.
Have this step after the DATA step. This code basically creates a XML formatted file similar to the PUT statement & writes it to a PS file WELLS.PS.FILE.LRECL-10000.RECFM-VB
Code: |
ODS LISTING CLOSE;
ODS MSOFFICE2K FILE='WELLS.PS.FILE.LRECL-10000.RECFM-VB' STYLE=NORMAL RS=NONE;
PROC PRINT DATA = FILE2 NOOBS;
RUN;
ODS MSOFFICE2K CLOSE;
ODS LISTING;
|
After this step Have a SAS email step like the one below. This step emails the XML file WELLS.PS.FILE.LRECL-10000.RECFM-VB.
Code: |
//emailstep EXEC SAS
//HTMLOUT DD DSN=WELLS.PS.FILE.LRECL-10000.RECFM-VB,DISP=SHR
//SYSIN DD *
FILENAME EMAIL EMAIL
FROM = ("wells@yolo.com")
TO = ("wells@yolo.com"
"wells2@yolo.com")
REPLYTO=("wells@yolo.com")
SUBJECT="This is a nice formatted instream email."
TYPE='TEXT/HTML';
DATA _NULL_;
FILE EMAIL;
INFILE HTMLOUT;
INPUT;
PUT _INFILE_;
RUN;
|
The above email step sends the report as instream email.
If you want the report as attachment, then there are small tunings on the EMAIL step with ATTACH keyword. |
Also if I add this below code instead of PUT in the SAS code how will give the length for each field and calculation made for each field using CATX....
Code: |
ODS LISTING CLOSE;
ODS MSOFFICE2K FILE='WELLS.PS.FILE.LRECL-10000.RECFM-VB' STYLE=NORMAL RS=NONE;
PROC PRINT DATA = FILE2 NOOBS;
RUN;
ODS MSOFFICE2K CLOSE;
ODS LISTING;
|
|
|
Back to top |
|
|
vasanthz
Global Moderator
Joined: 28 Aug 2007 Posts: 1742 Location: Tirupur, India
|
|
|
|
You don't need the CATX steps as well.
In your original approach
1. You read some data from external file
2. Append some spaces using CATX.
3. Write the appended values into output ps file.
4. read the output file in email step
In the approach that I am suggesting,
1.Read the file
2. create XML file using ODS.
3. email the file. |
|
Back to top |
|
|
|