Desktop productivity for business analysts and programmers

combine two codes

Reply
Contributor
Posts: 30

combine two codes

[ Edited ]

I have this code that send out email with text in the email from a email address found in the data pulled (code 1)and i have another code that makes a excel file for each email/person and email that(code 2) what I want to do is match the email/names in both codes  and attach the excel file from code 2 to code 1 email  and get rid of the email in code 2 all together.


/*code1*/
filename output email subject ="Unseen" to= &Provider_Email from='' attach = ( CT= 'text/html'; ODS HTML BODY=output STYLE=CBD_STANDARD rs=none; /*solutions*/ ods escapechar='^'; options missing=' '; proc print data=x label noobs; /*^{Style [color=red textdecoration=underline Height=14pt font_weight=bold] Diagnoses can NO longer be captured through an Online Encounter, Secure Message, or Clin Doc.}*/ title1 j=left font=light Height=4 "^{Style [color=black] Hello &FIRST_NAME,}"; title2 ' '; title3 j=left font=light Height=4 "^{Style [color=black] ^{newline 2} ^{Style [color=black] "; run; ods HTML close; filename output clear; /*Delete final_email_list_filter*/ proc datasets; delete final_email_list_filter; %mend nocomp_email; data _null_; set EMAILER_SUMMARY; call execute('%nocomp_email( Provider_Email ="'||TRIM(LEFT(EMAIL))||'",'|| 'FIRST_NAME =" '||TRIM(PROPCASE(LAST_NAME))||' ")' ); run; %END; %MEND EMAILER; %EMAILER;

 

Super User
Posts: 9,548

Re: combine two codes

Run the excel export code before you send email "one", and use the attach= option there in the filename email.

 

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Contributor
Posts: 30

Re: combine two codes

Posted in reply to KurtBremser

how will the email (code 1) know to attach the excel file that matches the same name? 

Contributor
Posts: 30

Re: combine two codes

Posted in reply to KurtBremser

is there code that can tell the email to match the email address or names so that it only gets data and excel file for a specific person and sents that out. 

Super User
Posts: 3,761

Re: combine two codes

To dynamically email different recipients with different attachments you will need to use PUT statement email directives. This link to the documentation explains directives:

http://support.sas.com/documentation/cdl/en/lestmtsref/63323/HTML/default/viewer.htm#n0ig2krarrz6vtn...

Super User
Posts: 9,548

Re: combine two codes


hk2013 wrote:

is there code that can tell the email to match the email address or names so that it only gets data and excel file for a specific person and sents that out. 


First, set up a list of recipients in a dataset.

Then, wrap your code(s) in macro definitions where the recipient is accepted as a macro parameter.

Now you can use call execute() to call your macro(s) from the recipients dataset.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Ask a Question
Discussion stats
  • 5 replies
  • 305 views
  • 0 likes
  • 3 in conversation