Hi,
I'm new to SAS programing so any assistance will be great.
I have a data set which contains daily (day var) revenue, visit and order participation websites. It looks something like this:
web_Id | Start_Date | End_Date | Day | Revenue_Participation | Visits | Orders_Participation | Units_Participation |
1766618 | 2-Jun-15 | 13-Jul-15 | 2-Jun-15 | 0 | 322 | 11 | 55 |
1766618 | 2-Jun-15 | 13-Jul-15 | 3-Jun-15 | 959 | 283 | 17 | 90 |
1766618 | 2-Jun-15 | 13-Jul-15 | 4-Jun-15 | 0 | 266 | 15 | 66 |
1766618 | 2-Jun-15 | 13-Jul-15 | 5-Jun-15 | 0 | 268 | 13 | 37 |
1766618 | 2-Jun-15 | 13-Jul-15 | 6-Jun-15 | 0 | 259 | 7 | 46 |
1766618 | 2-Jun-15 | 13-Jul-15 | 7-Jun-15 | 454 | 300 | 13 | 72 |
1766618 | 2-Jun-15 | 13-Jul-15 | 8-Jun-15 | 0 | 390 | 14 | 58 |
1766618 | 2-Jun-15 | 13-Jul-15 | 9-Jun-15 | 0 | 352 | 21 | 65 |
1766618 | 2-Jun-15 | 13-Jul-15 | 10-Jun-15 | 0 | 304 | 17 | 63 |
1766618 | 2-Jun-15 | 13-Jul-15 | 11-Jun-15 | 0 | 304 | 10 | 54 |
1766618 | 2-Jun-15 | 13-Jul-15 | 12-Jun-15 | 66 | 291 | 16 | 84 |
1766618 | 2-Jun-15 | 13-Jul-15 | 13-Jun-15 | 0 | 233 | 8 | 39 |
1766618 | 2-Jun-15 | 13-Jul-15 | 14-Jun-15 | 0 | 338 | 18 | 70 |
1895471 | 17-Mar-15 | 4-May-15 | 17-Mar-15 | 0 | 106 | 0 | 0 |
1895471 | 17-Mar-15 | 4-May-15 | 17-Mar-15 | 0 | 834 | 16 | 52 |
1895471 | 17-Mar-15 | 4-May-15 | 18-Mar-15 | 0 | 96 | 0 | 0 |
1895471 | 17-Mar-15 | 4-May-15 | 18-Mar-15 | 858 | 812 | 9 | 17 |
1895471 | 17-Mar-15 | 4-May-15 | 19-Mar-15 | 0 | 89 | 0 | 0 |
1895471 | 17-Mar-15 | 4-May-15 | 19-Mar-15 | 0 | 726 | 4 | 13 |
1895471 | 17-Mar-15 | 4-May-15 | 20-Mar-15 | 0 | 655 | 14 | 59 |
1895471 | 17-Mar-15 | 4-May-15 | 20-Mar-15 | 200 | 71 | 1 | 1 |
1895471 | 17-Mar-15 | 4-May-15 | 21-Mar-15 | 0 | 83 | 0 | 0 |
1895471 | 17-Mar-15 | 4-May-15 | 21-Mar-15 | 0 | 703 | 11 | 32 |
1895471 | 17-Mar-15 | 4-May-15 | 22-Mar-15 | 0 | 111 | 0 | 0 |
1895471 | 17-Mar-15 | 4-May-15 | 22-Mar-15 | 0 | 768 | 13 | 36 |
1895471 | 17-Mar-15 | 4-May-15 | 23-Mar-15 | 169 | 117 | 1 | 2 |
1895471 | 17-Mar-15 | 4-May-15 | 23-Mar-15 | 657 | 701 | 4 | 11 |
1895471 | 17-Mar-15 | 4-May-15 | 24-Mar-15 | 0 | 88 | 0 | 0 |
1895471 | 17-Mar-15 | 4-May-15 | 24-Mar-15 | 0 | 639 | 8 | 33 |
What I need to do is sum the totals for Revenue_Participation, Visits , Orders_Participation and Units_Participation by week for each website (web_Id) during the specified campaign date range - between Start_date and end_date based off the day var.
I’d have a var call Week in the datset. The tricky part is the week does not begin on a Sunday or Monday, it begins on a tuesday and ends on monday. I'm looking for an ouput which looks like this (the counts don't match to the above):
web_Id | Week(starts on Tuesday) | Start_Date | End_Date | Revenue_Participation | Visits | Orders_Participation | Units_Participation |
1766618 | 6/9/2015 | 2-Jun-15 | 13-Jul-15 | 0 | 545 | 89 | 888 |
1766618 | 6/16/2015 | 2-Jun-15 | 13-Jul-15 | 55 | 653 | 65 | 363 |
1766618 | 6/23/2015 | 2-Jun-15 | 13-Jul-15 | 99 | 888 | 6658 | 783 |
I have been experimenting with code like this.
data week;
set have;
week_of=intnx('week',day,0,'B');
format week_of date9.; run;
Any help will be appreciated. Thanks!
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.