I have some data in week-date-time format ie 14dec2020:00:00:00:000. I am using SAS and a proc sql (SQL Server) pass through query
This data contains many weeks worth of data but I was curious if theres in way to only pull data relevant to only current week? IE today is 17dec2020 so I would want to only pull data for the week of 14dec2020. if today was 22dec2020 then I would want it to pull data for the week of 21dec2020.
Data macros;
today = today();
wkday = weekday(today);
start = today()-(wkday-1);
end = today+(7-wkday);
length cstart cend $22;
cstart = "'" || put(start, date9.) || ':00:00:00.000' || "'";
cend = "'" || put(end, date9.) || ':00:00:00.000' || "'";
call symput ('start', cstart);
call symput('end', cend);
run;
proc sql;
connect to odbc (dsn='x' uid='y' pwd='z');
create table work.pleasehelp as select * from connection to odbc
(select Year, Month, Week, store, sales, SKU
from datatable
Where (&start. <= Week and week <= &end.)
order by SKU);
disconnect from odbc;
quit;
There macros data set returns the proper date boundaries but when it tries running the PROC SQL it runs indefinitely. I ran it for 16 minutes and it only had a CPU run time of 1.09 seconds on it. I've tried changing the cstart and cend to just start and end throughout the queries but that runs with no matches.
Any help here would be appreciated!
datatablecolumnsyearmonthandweek? Are they SQL Server date types who values are the start of the represented interval ? Isdatatablea view ? What result set do you see if you execute the same passthrough query in a tool such a SQL Server Management Studio (SSMS) ? - Richard