I need to create an automated report with a moving date. One that goes back a few weeks to present (with a 3 day lag).
I created a macro for the date here:
%let start = %sysfunc(intnx(day,%sysfunc(today()),-22), date9.);
%let end = %sysfunc(intnx(day,%sysfunc(today()),-3), date9.);
The goal is to create a line graph that will only show data between the 'start' and 'end' variables. Code for graph:
proc sgplot data=nine noborder;
where date >= '&start'd and date <= '&end'd;
vline date / response=admit_ma y2axis lineattrs=(color=blue thickness=4)
DATALABELPOS=data name='c';
xaxis discreteorder=data display=(noline nolabel noticks) fitpolicy=thin;
y2axis display=(noline noticks) grid label='New COVID Hospital Admissions' values=(0 to 1.0 by 0.1) offsetmin=0;
keylegend 'c'/ title='' linelength=24 noborder;
label admit_ma='Number of new admissions';
run;
I know this probably isn't the best way, but I am modeling after an old code that was being used. The error I get is based off the date variables:
ERROR: Invalid date/time/datetime constant '&start'd.
ERROR: Invalid date/time/datetime constant '&end'd.
Error: Syntax error while parsing WHERE clause.