I am trying to take daily data (not every day has data) and sum it by weeks starting on monday. Below is a very small sample for the Data I have. the code is irrelvant for the summing purposes needed here.
Data have:
| ID | PKG | Revdt | code | QTY |
|---|---|---|---|---|
| 70 | 17AB | 02AUG2021:00:00:00 | 01 | 7 |
| 70 | 17AB | 04AUG2021:00:00:00 | 02 | -10 |
| 70 | 17AB | 05AUG2021:00:00:00 | 01 | 8 |
| 70 | 17AB | 10AUG2021:00:00:00 | 01 | 7 |
| 70 | 17AB | 1QAUG2021:00:00:00 | 01 | 7 |
| 73 | 12AC | 02AUG2021:00:00:00 | 09 | 0 |
| 73 | 17AC | 07AUG2021:00:00:00 | 01 | 7 |
Data want
| ID | PKG | Revdt | code | QTY |
|---|---|---|---|---|
| 70 | 17AB | 02AUG2021:00:00:00 | 01 | 5 |
| 70 | 17AB | 09AUG2021:00:00:00 | 01 | 14 |
| 73 | 12AC | 02AUG2021:00:00:00 | 01 | 7 |
I have tried the below
Proc sql;
connect to odbc (dsn='' id='' p='');
create table work.WeeklySum as select distinct * from connection to odbc
(select ID, Pkg, datepart(week, revdt), code, sum(qty)
from datebase
group by datepart(week, revdt) );
disconnect from odbc;
quit;
However when i run it, it says "error:proc sql requires any created table to have atleast 1 column"