A couple of things to help you out. The first is using the INTNX function to define the date range. First off you want to create macro variables representing the past 12 months ending last month (since the current month is not complete):
%global prev_month &prev12_month;
data date_parms;
analysis_date=today();
prev_month=intnx('month',analysis_date,-1);
prev12_month=intnx('month',analysis_date,-12);
call symputx('prev_month',prev_month);
call symputx('prev12_month',prev12_month);
run;
You now have two macro variables representing the first day of the previous and 12 months ago.
To subset the data for a single state and the time period is simple;
Assumption is that the dta has been imported into SAS table PERFORMANCE.
%macro state_date(dsnout=,state=);
data &dsnout;
set performance;
where state="&state" and intnx('month',date,0) between &prev12_month and &prev_month;
run;
/* Insert chart code here */
%mend;
%state(dsnout=California, state=CA);
This will create a SAS table named California containing CA records for the past 12 months. If you insert chart code you can create a chart with the macro.
There are ways that you can build charts for all possible combinations of state and company by identifying unique combinations and then running them through a do loop. Hope this gets you in the right direction.