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_ID | Purchase_Date | Name | Phone | Email_Txt |
101 | 1/1/2016 | jon | 123 | You are getting this email because you have purchased this item on 01/01/2016 |
101 | 1/2/2016 | smith | 456 | You are getting this email because you have purchased this item on 01/02/2016 |
201 | 1/5/2016 | KAY | 789 | You are getting this email because you have purchased this item on 01/05/2016 |
201 | 1/3/2016 | TOM | 654 | You are getting this email because you have purchased this item on 01/03/2016 |
201 | 1/2/2016 | JILL | 741 | You 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_ID | Purchase_Date | Name | Phone | |
101 | 1/1/2016 | jon | 123 | |
101 | 1/2/2016 | smith | 456 | |
You are getting this email because you have purchased this item on 01/02/2016 | ||||
Purchase_ID | Purchase_Date | Name | Phone | |
201 | 1/5/2016 | KAY | 789 | |
201 | 1/3/2016 | TOM | 654 | |
201 | 1/2/2016 | JILL | 741 |
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:
|
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
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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.