BookmarkSubscribeRSS Feed
tekish
Quartz | Level 8

Dear experts,

 

I want to create an automated email with different table  inside the order list.

here is the sample output.

 

 

Subject: list of variable from Sashelp

Dear [ Name]:

  1. Name of student from sashelp.
  2. List of student below with age eleven. 

Name

Sex

age

Height

Weight

Joyce

F

11

51.3

50.5

Thomas

M

11

57.5

85

 

    3.List of student below with age eleven.

Name

Sex

age

Height

Weight

Joyce

F

11

51.3

50.5

Thomas

M

11

57.5

85

 

Thank you for you for helping .

 

 

here is the sample SAS codes.

data class;

set sashelp.class;

run;

PROC SORT DATA=CLASS;

BY AGE;

RUN;

%MACRO test(FLD,RECIPIENT_EMAIL,RECIPIENT_NAME,LEVEL);

FILENAME MYMAIL EMAIL

TO = "emailadderess@test1.com"

FROM = "emailadderess@test1.com"

SENDER = "emailadderess@test1.com"

REPLYTO = "emailadderess@test1.com"

BCC = "emailadderess@test1.com"

CT = "TEXT/HTML";

DATA TEMP;

SET class;

BY age;

IF (&FLD = "&LEVEL");

RUN;

DATA _NULL_;

FILE MYMAIL;

SET TEMP END = EOF;

IF _N_ = 1 THEN DO;

 

 

%LET RECIPIENT_NAME=Name of the person;

/*TO = "&RECIPIENT_EMAIL";*/

 

 

TO = "emailadderess@test1.com";

PUT '!EM_TO! ' TO;

PUT '!EM_SUBJ! ' "list of variable from Sashelp &LEVEL";

PUT '<html><body><font face = "Cambria" size = "3" color = "000000">';

 

PUT "Dear &RECIPIENT_NAME;";

PUT '<p>';

PUT "<p>";

PUT "<p>";

PUT "<ol><li>Select <b>Name of student from sashelp</b></li>";

PUT "<li>list of student below with age 11 </b> section. </li>";

PUT '<p>';

PUT '<p>';

PUT '<p>';

PUT '<p>';

PUT '<table border = 1>';

PUT '<tr>';

PUT '<td><b>Name</b></td>';

PUT '<td><b>sex</b></td>';

PUT '<td><b>age</b></td>';

PUT '<td><b>height</b></td>';

PUT '<td><b>weight</b></td>';

PUT '</tr>';

END;

 

PUT '<tr>';

PUT '<td>' Name '</td>';

IF sex=M THEN

PUT '<td> <font color=#FF6342><b>' sex '</font></b></td>';

ELSE PUT '<td>' sex '</td>';

IF age=14 THEN

PUT '<td> <font color=#FF6342><b>' age '</font></b></td>';

ELSE PUT '<td>' age '</td>';

IF height>10 THEN

PUT '<td> <font color=#FF6342><b>' height '</font></b></td>';

ELSE PUT '<td>' height '</td>';

IF weight<30 THEN

PUT '<td> <font color=#FF6342><b>' weight '</font></b></td>';

ELSE PUT '<td>' weight '</td>';

PUT '</ol>';

PUT '</tr>';

 

IF EOF THEN DO;

PUT '</table>';

PUT '</body></html>';

END;

PUT "<li>list of student above with age 11 </b></li>";

PUT '</ol>';

PUT '</tr>';

PUT '<table border = 1>';

PUT '<tr>';

PUT '<td><b>Name</b></td>';

PUT '<td><b>sex</b></td>';

PUT '<td><b>age</b></td>';

PUT '<td><b>height</b></td>';

PUT '<td><b>weight</b></td>';

PUT '</tr>';

END;

 

PUT '<tr>';

PUT '<td>' Name '</td>';

IF sex=M THEN

PUT '<td> <font color=#FF6342><b>' sex '</font></b></td>';

ELSE PUT '<td>' sex '</td>';

IF age=14 THEN

PUT '<td> <font color=#FF6342><b>' age '</font></b></td>';

ELSE PUT '<td>' age '</td>';

IF height>10 THEN

PUT '<td> <font color=#FF6342><b>' height '</font></b></td>';

ELSE PUT '<td>' height '</td>';

IF weight<30 THEN

PUT '<td> <font color=#FF6342><b>' weight '</font></b></td>';

ELSE PUT '<td>' weight '</td>';

PUT '</ol>';

PUT '</tr>';

 

IF EOF THEN DO;

PUT '</table>';

PUT '</body></html>';

END;

 

 

RUN;

FILENAME MYMAIL CLEAR;

%MEND test;

 

PROC SORT DATA=class OUT=DRIVER_AGE(KEEP=age) NODUPKEY;

BY age;

RUN;

 

DATA _NULL_;

SET DRIVER_AGE;

BY age;

IF age=11;

CALL EXECUTE('%test(AGE,'||RECIPIENT_EMAIL||','||RECIPIENT_NAME||','||AGE||')');

RUN;

1 REPLY 1
lakshmi_74
Quartz | Level 8

In your point of view, Do you want to create a mail list to each student. Is it correct?

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 739 views
  • 0 likes
  • 2 in conversation