BookmarkSubscribeRSS Feed
TarunKumar
Pyrite | Level 9

Hi Guys,

I have data of our sales team in sas data set.

emp_codenamedeptli_revenuemf_revenuegi_revenueTotal_Revenueemail_id
1aSALES500002005200ABC@MAIL.COM
2bSALES1000030004000BC@MAIL.COM
3cSALES2000250040008500AS@MAIL.COM
4bSALES30003600500011600GB@MAIL.COM
5eSALES40050060006900DB@MAIL.COM

Want to create Detail report and want same is email as Attachment or Mail Body .

emp code 1

Subject :- Issued Revenue

Dear a,

Revenue done in the month of Jun15.

Li Revenue --5000/-

MF Revenue -- 0/

Gi Rebvenue -- 200/

Total Revenue -- 5200/-

Regard

XYZ Bank

Corporate Office

3 REPLIES 3
LinusH
Tourmaline | Level 20

You'll probably need to do this in a data step.

There are lot of examples you learn from at support.sas.com.

Data never sleeps
Ksharp
Super User

Post it at ODS and REPORT forum , Cynthia has done it before .

AmitRathore
Obsidian | Level 7

Hi Tarun,

Please see below code if it works for you:

filename nwfile 'C:\temp\sales.txt';

data sales;

  length email_id $ 25;

  infile nwfile ;

  input emp_code $ name $ dept $ li_revenue $ mf_revenue $ gi_revenue $ total_revenue $ email_id $;

run;

proc transpose data = sales out = newsales name=variable prefix = value;

  by emp_code name email_id;

  var li_revenue mf_revenue gi_revenue total_revenue;

run;

data newsales1;

  set newsales;

  call symput(trim(variable)||trim(emp_code), value1);

  call symput("_"||trim(emp_code), email_id);

run;

%put _user_;

%macro MAILME( _to = 

  ,_cc = 

  ,_subject = 

  ,_attach =

  ,_text1 =

  ,_text2 = 

  ,_text3 =

  ,_text4 = 

  );

  options emailsys=smtp emailhost=smtp.ferring.com emailport=25;

  filename maily email (&_to) 

  To = (&_to)

  CC = (&_cc)

  subject = "&_subject"

  %if &_attach ne NO %then %do; attach = "&_attach" %end;;

  data _null_;

   file maily;

   put "THIS IS AN AUTO GENERATED E-MAIL";

   put "&_text1";

   put "&_text2";

   put "&_text3";

   put "&_text4";

   put " ";

   put "REGARDS";

   put "XYZ Bank";

   put "Corporate Office";

  run;

%mend;

%macro chk;

%do i = 1 %to 1;

  %MAILME(_to = "&&_&i."

  ,_cc = "&&_&i."

  ,_subject = Issue Revenue

  ,_attach = NO

  ,_text1 = Li Revenue -- &&li_revenue&i./-

  ,_text2 = MF Revenue -- &&mf_revenue&i./-

  ,_text3 = GI Revenue -- &&gi_revenue&i./-

  ,_text4 = Total Revenue -- &&total_revenue&i./-

  );

%end;

%mend;

%chk

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
  • 3 replies
  • 2004 views
  • 0 likes
  • 4 in conversation