DATA Step, Macro, Functions and more

Want to create detail Report

Reply
Frequent Contributor
Posts: 78

Want to create detail Report

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

Super User
Posts: 5,435

Re: Want to create detail Report

Posted in reply to TarunKumar

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
Super User
Posts: 10,041

Re: Want to create detail Report

Posted in reply to TarunKumar

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

Contributor
Posts: 21

Re: Want to create detail Report

Posted in reply to TarunKumar

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

Ask a Question
Discussion stats
  • 3 replies
  • 224 views
  • 0 likes
  • 4 in conversation