The SAS Output Delivery System and reporting techniques

Help using #byval in PROC REPORT

Reply
Frequent Learner
Posts: 1

Help using #byval in PROC REPORT

Hello fellow SAS programmers,

 

I am tring to create a report notification where a group of people get an email saying that they have purchased an item on so on date with a list of other induvuduals who have purchased the same/similar item.

 

Here is my table:

 

Purchase_IDPurchase_DateName PhoneEmail_Txt
1011/1/2016jon123You are getting this email because you have purchased this item on 01/01/2016
1011/2/2016smith456You are getting this email because you have purchased this item on 01/02/2016
2011/5/2016KAY789You are getting this email because you have purchased this item on 01/05/2016
2011/3/2016TOM654You are getting this email because you have purchased this item on 01/03/2016
2011/2/2016JILL741You are getting this email because you have purchased this item on 01/02/2016

 

I want to creat a report that will look like:

 

You are getting this email because you have purchased this item on 01/01/2016
     
Purchase_IDPurchase_DateName Phone 
1011/1/2016jon123 
1011/2/2016smith456 
     
You are getting this email because you have purchased this item on 01/02/2016
     
Purchase_IDPurchase_DateName Phone 
2011/5/2016KAY789 
2011/3/2016TOM654 
2011/2/2016JILL741 

 

My Code:

proc sort data=book3 out=temp101;
	by Purchase_ID EMAIL_TXT;
run;

options nobyline;

proc report data=temp101 nowd headline headskip wrap;
	by Purchase_ID EMAIL_TXT;
	column Purchase_Date Name Phone;
	define Purchase_Date/'Purchase Date';
	define Name/'Customer Name';
	define Phone/'Customer Phone';
	title1 justify=left "NOTIFICATION";
	title justify=left "#byval2";
run;
 

When I run the code, I am uinable to group records by Purchase_ID with title as EMAIL_TXT using the #byval.

 

Here is my output report:

You are getting this email because you have purchased this item on 01/01/2016

Purchase Date Customer Name Customer Phone
01JAN2016jon123

You are getting this email because you have purchased this item on 01/02/2016

Purchase Date Customer Name Customer Phone
02JAN2016smith456

You are getting this email because you have purchased this item on 01/02/2016

Purchase Date Customer Name Customer Phone
02JAN2016JILL741

You are getting this email because you have purchased this item on 01/03/2016

Purchase Date Customer Name Customer Phone
03JAN2016TOM654

You are getting this email because you have purchased this item on 01/05/2016

Purchase Date Customer Name Customer Phone
05JAN2016KAY789

 

 

Is there a way I can group all records under one Purchase_ID with EMAIL_TXT as Title?

 

Any help will be much appreciated!

 

Thanks in advance

 

 

Frequent Contributor
Posts: 92

Re: Help using #byval in PROC REPORT

The EMAIL_TXT in your data varies for each record within a PURCHASE_ID.  That's why you see jon and smith listed separately, even though they both have the same PURCHASE_ID. 

Ask a Question
Discussion stats
  • 1 reply
  • 140 views
  • 0 likes
  • 2 in conversation