BookmarkSubscribeRSS Feed
dcortell
Pyrite | Level 9

Hi all

 

With the below code

proc format;

 value color 
 0-5="YELLOW"
 5-10="ORANGE"
 10-15="SALMON"
 15-high="RED";

 picture pctfmt (round) other='009.99%';

 value color_attend 
 0-30="PALG"
 30-60="VLIYG"
 60-80="BILG"
 80-high="GREEN|G";
 
run; 

 

 

filename outbox email ""  TO=()
FROM=()
subject="Actualizacion sobre Lead sin cerrar cumulados por Lead Owner. Fecha : &today"

attach=("~/Chart_of_delay.pdf" "~/Chart_of_delay_event_only.pdf"
        "~/Pending_leads.csv" "~/Lead_outcome_dictionary.docx"

content_type="application/docx")
lrecl=256 
type="TEXT/HTML";
    

ods _all_ close;

ods html3 body=outbox style=sasweb;

options nocenter;


ods listing;

data _null_;
 file print ;
 put '<html><body>'; 
 put 'Estiamdos<br>Adjuntos en este correo encontrais :';
 put '<ul><li>Fichero Excel con la lista de todos los leads(columna: lead_id) relacionados a cada'; 
 put 'lead owner (columna : lead_owner_name) y todavia en estado Not_started o En_progress.';
 put 'Además, por cada lead hay la cantidad de tiempo pasada sin actuar desde su creación'; 
 put 'hasta hoy (columna: Delay_in_progress), y otras informaciones relacionada al contacto'; 
 put 'del lead.</li>';
 put '<li> En pdf, el ranking grafico de los lead owners que mas están cumulando lead sin actuar';
 put 'en los ultimos 365 dias, y el numero de leads cumulado</li>';
 put '<li>Un file txt donde hay por cada tipo de lead_outcome su descriptivo, detallando el';
 put 'significado de cada tipo de cierre. De esa manera esperamos aclarar las dudas sobre';
 put 'como cerrar de manera correcta un lead</li></ul><br>';
 put 'La idea del fichero y del grafico es de suportar vuestra gestión de los leads,';
 put 'y facilitar una visión continua de la cantidad de pendientes que necesitan';
 put 'ser actuados.<br>';
 put 'Como ya sabéis, cada lead necesita recibir un lead_outcome para considerarse cerrado en';
 put 'Orion, y permitir al deparatamento de analysis de Marketing de analizar los resultados';                
 put 'de los esfuerzos promocionales conjuntos de Marketing & Ventas. Mas tiempo siguen los';
 put 'leads sin un resultado final, mas sube la posibilidad de tener metricas no alineadas.<br>';
 put 'El equipo de Marketing esta a vuestra disposicion para aclarar culaquier duda sobre el';
 put 'fichero o el proceso de cierre de los leads.<br>';
 put 'El reporte se enviara cada 7 dias de manera actualizada.<br>';
 put 'Un saludo<br>';
 put 'xx';
 put '</body></html>';


run; 


PROC TABULATE data=open_lead2  ;
CLASS   lead_owner_name Delay_in_progress2 / MISSING;
VAR ;
TABLE (lead_owner_name all) ,
( Delay_in_progress2 all) * (N colpctn*f=pctfmt.*{ style=[background=color.]}) ;
RUN; 



ods listing close;
ods _all_ close;

I get the following email result below. The code seems not working as supposed as

 

a. The html tags seems not recognized by the code. The <ul><li> which should create bullet points list do not work

 

b. the <br> tag which should create break too seems not recognized

 

c. The result of the proc tabulate for some reason got deformed, with the first column getting a weird error in one cell, which make it enlarging a lot

 

d. some grey cells show up, when there should be values with colours

 

Capture.PNG

 Capture.PNG

Does someone knows why the combination html + tags is not working as supposed?

 

Bests                                                                                                                      

4 REPLIES 4
ChrisHemedinger
Community Manager

Your PUT statements open and close the HTML Body...and then you have PROC TABULATE output that is included after that.  The result would be invalid HTML.

 

To modernize this a bit, consider using PROC ODSTEXT and PROC ODSLIST to create your "prose" -- the narrative content that comes before the PROC TABLULATE output -- instead of using DATA step and PUT statements.

 

You might also consider using ODS MSOFFICE2k instead of HTML3.  It's still "generic" enough to work with most e-mail clients.

Learn from the Experts! Check out the huge catalog of free sessions in the Ask the Expert webinar series.
dcortell
Pyrite | Level 9

Hi Chris

 

I tried your approach with

 

 

%let today=%sysfunc(today(),date9.);
%put &today;
 

filename outbox email ""  TO=("")
FROM=("")
subject="Actualizacion sobre Lead sin cerrar cumulados por Lead Owner. Fecha : &today"

attach=("~/Chart_of_delay.pdf" "~/Chart_of_delay_event_only.pdf"
        "~/Pending_leads.csv" "~/Lead_outcome_dictionary.docx"

content_type="application/docx")
lrecl=256 
type="TEXT/HTML";
    

ods _all_ close;

/*ods html3 body=outbox style=sasweb;*/

options nocenter;

ods listing;

ods MSOFFICE2k body=outbox style=sasweb; options nocenter;


proc odstext;
   p 'Estiamados:' ;
   p " ";
   p 'Adjuntos en este correo encontrais :' ;
   list;
      item ;
      p'Fichero Excel con la lista de todos los leads(columna: lead_id) relacionados a cada';
      p'lead owner (columna : lead_owner_name) y todavia en estado Not_started o En_progress.'; 
      p'Además, por cada lead hay la cantidad de tiempo pasada sin actuar desde su creación';
      p'hasta hoy (columna: Delay_in_progress), y otras informaciones relacionada al contacto del';
      p'lead.';
	  end;

      item;
      p'En pdf, el ranking grafico de los lead owners que mas están cumulando lead sin actuar';
      p'en los ultimos 365 dias, y el numero de leads cumulado.';
	  end;

      item;
      p'Un file txt donde hay por cada tipo de lead_outcome su descriptivo, detallando el'; 
      p'significado de cada tipo de cierre. De esa manera esperamos aclarar las dudas sobre como'; 
      p'cerrar de manera correcta un lead.';
	  end;
   end;

   p 'La idea del fichero y del grafico es de suportar vuestra gestión de los leads, y facilitar';
   p 'una visión continua de la cantidad de pendientes que necesitan ser actuados.'; 
   p ' ';
   p 'Como ya sabéis, cada lead necesita recibir un lead_outcome para considerarse cerrado en';
   p 'Orion, y permitir al deparatamento de analysis de Marketing de analizar los resultados de'; 
   p 'los esfuerzos promocionales conjuntos de Marketing & Ventas. Mas tiempo siguen los leads'; 
   p 'sin un resultado final, mas sube la posibilidad de tener metricas no alineadas.';
   p ' ';
   p 'El equipo de Marketing esta a vuestra disposicion para aclarar culaquier duda sobre el'; 
   p 'fichero o el proceso de cierre de los leads.';
   p ' ';
   p 'El reporte se enviara cada 7 dias de manera actualizada.';
   p 'Un saludo,';
   p 'Davide';
run;


title ' Leads cumulados por meses sin actuar, en los ultimos 365 dias';
PROC TABULATE data=open_lead2 ;
CLASS   lead_owner_name Delay_in_progress2 / MISSING;
VAR ;
TABLE (lead_owner_name all) ,
( Delay_in_progress2 all) * (N colpctn*f=pctfmt.*{ style=[background=color.]}) ;
RUN; 



ods listing close;
ods _all_ close;

filename outbox clear;

 

And the result are below and ambiguos. While the Text seems working almost fine (despite too much space within the bullet points line), the proc tabulate result is not working properly.

 

Some cells do not receive the format associated, some row labels get a format different from the rest of the table, and some total cells become grey.

 

Any suggestion on what shold be the topic here?

Bests

Capture.PNG

 Capture.PNG

 

ChrisHemedinger
Community Manager

Wow, PROC ODSTEXT does seem a lot cleaner -- even if we're not all the way there yet.

 

E-mail clients (like Outlook) don't always render HTML in the most faithful way.  You can try different styles -- instead of sasweb, try HTMLBlue.  Also try Minimal...just to see what happens.

 

I assume that this output looks okay when you generate it outside of an e-mail?

 

Also, is there are reason that you're turning on ODS LISTING as part of this? It doesn't look like you are relying on LISTING output.  Having multiple ODS destinations open can cause some of the ODS options to "cross over" into the different destinations.

Learn from the Experts! Check out the huge catalog of free sessions in the Ask the Expert webinar series.
dcortell
Pyrite | Level 9

Hi Chris

 

- the ods listing were there as residual of an initial version of the code. however, also without it the results do not change

 

- i have tried different styles, htmlblue, sasweb, a personalized one..the result it is the same. Grey background in some cells, some cells do not receive the red-yellow-orange format

 

- I tested the style=minimal. The result is that grey cells disappear, but I get the following weird results in some cells of the proc tabulate outcome:

 

Capture.PNG

 

   - still some cells do not receive the heat format

   - one of them get strange markups

 

The output are ok where they generate outside an email

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 3911 views
  • 0 likes
  • 2 in conversation